I have migrated frameworks from prototype to jQuery in my Rails apps, and I'm running into a consistent problem which I need some advice on.
Often times I'll use an AJAX function that updates a portion of the page. When this happens, any other Javascript I use that relates to the section of the page that was updated no longer works. What's the best way around this?
Most of my javascript lives inside jQuery(document).ready(function() { }); with some functions that live outside this method. I've been getting around this by relying on the jQuery .live() handler, or by calling the function I want to 'reinitialize' in my js.erb files.
What's the best approach? Should I:
- explicitly call functions by name to work as part of the callback to get them to work
- continue to use the .live() for submit/click events
- or is there better, more efficient way to deal with this
Looking forward to your feedback everyone and thanks for your advice.
-A