I'm involved with updating a Rails appp from 2.2 to 3.0, specifically in dealing with the changes for unobtrusive Javascript for the AJAX portions of the application.
The move to JQuery is going pretty much as expected, but the one area I'm having a bit of philosophical trouble with is the implementation of history control for the AJAX loads. Using BBQ, I've implemented things just fine for moving forward and back. However, I'm having a problem with how to handle deep bookmarking and refreshes.
Most of the time when a new partial loads, another bit of Javascript needs to be initialized (for sortable tables, for instance). In the regular flow of clicking from one load to the next, the complete (and success and error) functions associated with the AJAX call take care of calling the follow-up JS initializations. However, when a page is bookmarked or refreshed, there's no clear way to define the Javascript that's supposed to come next.
Previously, the necessary JS was included and executed within script tags in the fragment itself, but this method doesn't really follow the UJS pattern. There's a bunch of stuff I could do, like make some ridiculous object with fragment URLs as keys with their associated functions, or add extra node elements in the fragments with something like a "data-function" attribute to execute at the time of load (a less ridiculous option, though slightly more complicated if there are child nodes loading).
Anyway, I'd like to know what the generally accepted pattern is for this type of thing. Most of what I've found is pretty much along the inline script variety, but, clearly, that's not really keeping in the spirit of UJS.
Any resources or directions would be great. I'd really appreciate the input.