diff --git a/src/ajax.js b/src/ajax.js index a868239..716416f 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -260,8 +260,10 @@ Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { if (receiver = $(receiver)) { if (options.insertion) { - if (typeof options.insertion == 'string') - receiver.insert( {}[options.insertion] = response ); + if (typeof options.insertion == 'string') { + var insertion = {}; insertion[options.insertion] = response; + receiver.insert(insertion); + } else options.insertion(receiver, response); } else receiver.update(response); diff --git a/test/unit/ajax.html b/test/unit/ajax.html index 8218be0..100bf70 100644 --- a/test/unit/ajax.html +++ b/test/unit/ajax.html @@ -107,6 +107,12 @@ new Ajax.Updater("content", "fixtures/content.html", { method:'get', insertion: 'bottom' }); wait(1000,function(){ assertEqual(sentence, $("content").innerHTML.strip().toLowerCase()); + + $('content').update(); + new Ajax.Updater("content", "fixtures/content.html", { method:'get', insertion: 'after' }); + wait(1000,function(){ + assertEqual('five dozen', $("content").next().innerHTML.strip().toLowerCase()); + }); }); }); }},