Hey all,
I have an action that calls render() to render an initial page view. This page loads several jQuery plugins and also uses ajaxStart/ajaxStop to show a ‘loading’ div when an ajax call is fired off. There are several buttons on the page that make ajax calls to load variable content into a #panel div.
The first click of any of these buttons fires off the ‘loading’ div and gets the new content. Any subsequent click of any of the buttons gets the new content but does not fire the ajaxStart event and so the ‘loading’ div does not display. A page refresh to the initial render()'d page restores the ‘loading’ functionality but again only for the first click.
The JS file that contains the ajaxStart and ajaxStop code is loaded into the initial page render(), and it’s related div is outside of #panel, so why are the bindings getting hosed when I call Yii’s renderPartial? The partial does not contain any elements that have bindings that require live() or listen() so should be completely separate from the javascript and elements that are loaded on initial render().
My guess is that because I have renderPartial set to processOutput (there’s a CStarRating that needs to be handled), that renderPartial is wiping out the previous javascript by resending all core javascript files to the client because of the widget in the response.
This causes another issue as well. If the javascript gets resent (verified by firebug), the number of ajax requests doubles with each click of an ajax-enabled element because each time it’s called, it adds yet another version of the javascript to the final page.
How can I get renderPartial to leave the initial javascript alone but still have it parse the widget jQuery in the partial? Specially since the initial javascript doesn’t do anything with the elements in the partial?