If there is $(document).ready() in CListView itemview, then the ready() function only be called for the first time. Once switch to diffrent page, the $(doc).ready function won’t be called again.
I’ve been having similiar problems with CListView and pagination. In my case links that use jquery on the subsequent pages appear to have lost the click eventhandler. The issue resolves it self with a page refresh or a button click on an ajax element on the same page.
I’m not sure what the solution is. I’d hope that the more experienced folks would chime in.
Originally, I thought the answer might be in where the .ready() function was called but it is obvious that it needs to wrap the jquery on each specific page so it would not be possible to call it at a different higher context. Just thinking out loud.
I read somewhere that linking too many jquery libraries can cause problems. I’m still not sure how to prevent loading more than one jquery library.
I’m missing something. I really like to understand these issues so that I could be more productive. No fun spinning your wheels.
Yii called $(document).ready() as well. So the code we write in ready() will be overwrite by Yii. So I think we just need to use Yii::app()->getClientScript()->registerScript, or registerScriptFile register the js code instead of putting it directly inside ready().
This new event-delegation code is connected to the "body", and is looking out for click events bubbling up from any underlying elements of class ".sayHello".
It does this, regardless of whether these elements still have their own attached click-events or not.
Since the event-delegation code is connected to the "body", you can add the "sayHello" class to any underlying element in the "body" - such as gridview buttons, links, pictures, etc.