Ajax Updater mystery

I have a form which contains the following updater:

When I use this form in a ‘new’ action, it works as expected. However,
When I try it with an 'edit/ action, it fails to call
updtrecipients,
and instead calls edit, which renders the whole page into
div_recipients.
I have noticed in the logs that params contains :id=>‘updtrecipients’
when this happens. Anyone know what’s going on? For now I have just
added
if request.xhr?
updtrecipients and return true
end
to the top of my edit action, which works, but if anyone has a solution
that is less ugly, I’d like to know what it is.

Thanks much

Ken

I use the words you taught me. If they don’t mean anything any more,
teach me others. Or let me be silent.
Samuel Beckett (Clov, Endgame)

Hello Kenneth,

2007/5/1, Kenneth D. [email protected]:

   onClick="new Ajax.Updater('div_recipients',
                             'updtrecipients',

{asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)}
); return false;">

Your problem is the URL of the Updater. You’re telling it to POST
relative to the current URL.

If you have /contacts/new, you’ll get /contacts/updtrecipients, and if
you have /contacts/edit/13, you’ll get /contacts/edit/updtrecipients.

You’re much better off using absolute URLs, or using named routes
(which give you absolute URLs always).

Hope that helps !

François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

Quoth Fran??ois Beausoleil ([email protected]):

If you have /contacts/new, you’ll get /contacts/updtrecipients, and if
you have /contacts/edit/13, you’ll get /contacts/edit/updtrecipients.

You’re much better off using absolute URLs, or using named routes
(which give you absolute URLs always).

Hope that helps !

That seems to have done the trick. Thanks.

Ken

I use the words you taught me. If they don’t mean anything any more,
teach me others. Or let me be silent.
Samuel Beckett (Clov, Endgame)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs