0

I thought this would be fairly simple but it turns out not to work as I thought it would or should.

new Ajax.Updater('myContainer','/url/',{
   insertion: {before: 'anotherElementId'}
});

How is this done correctly?

James Allardice
  • 164,175
  • 21
  • 332
  • 312
SquareCat
  • 5,699
  • 9
  • 41
  • 75

1 Answers1

1

As stated in the docs for Ajax.Updater:

The insertion option takes one of four strings — top, bottom, before, or after

You are passing an object literal, which is why it does not work. The element referred to by the first argument to Ajax.Updater is the one which will be modified. That's the whole idea of that method (as a shorthand instead of doing the insert manually in a normal AJAX request callback).

So I think what you were aiming for was this:

new Ajax.Updater('anotherElementId','/url/',{
   insertion: 'before'
});
James Allardice
  • 164,175
  • 21
  • 332
  • 312
  • You are absolutely right. I missed that point entirely! I got confused by the way insertion works in other cases. Thank You! – SquareCat Jun 17 '12 at 22:23