Rails 3 AJAX remote form call backs
Wow, that was a colossal waste of an evening.
Doing it the way I did, the default prototype rails.js
won't linkup the callbacks.
After converting to the jQuery based rails.js
(http://github.com/rails/jquery-ujs) callbacks are working fine.
You can trigger the Prototype-based callbacks like so:
$('formname').observe('ajax:before', function(){ ...});$('formname').observe('ajax:complete', function(request){ ...});
However, I don't think the request
object in the ajax:complete
callback contains the response. I'm used to jQuery and had hoped that accessing the response would be simple. Instead, it looks like switching to jQuery-Rails may still be easier, as I can't seem to find drop-in Prototype code to replace the :update
functionality from Rails 2 remote helpers.
If the accepted answer don't fixed your problem, check if you have embedded multiple jQuery libraries. In my case I had two different version of jQuery embedded and after removing one of them, everything worked fine.