I’m developing a web-app in Rails using jQuery where a lot of the processing is via AJAX POSTs of forms. I need to set up handlers for the various “ajax:” events (ajax:success, ajax:failure), which I think trigger on the <form> element.
Due to Rails, it’s easy for me to add a class to the <input type="submit"> elements, but not always easy to add a class to the surrounding form. Finally, because I’m using AJAX to update the page, I obviously want to bind the handlers to any newly-added forms that need them.
Is it possible, using live() or similar, to dynamically bind an event to the <form> tag which is the parent of each <input> tag with a given class that exists now or in the future?
The best way to do this would be to use jQuery’s global Ajax event handlers,