Yii CGridView javascript paginated event

I am extending CGridView in Yii using jQuery to remember checked rows when switching pages. Pages are loaded using AJAX, so I thought that when the request is complete and the new page is displayed, I want my code to take a step in magic. However, I cannot find any documentation that points to any event that will be fired, or so, when the new page finishes rendering.

I could use DOM listeners, but I decided that it would be better to use a single event for the entire page.

+5
source share
1 answer

You can use afterAjaxUpdate (since your pages load with ajax):

 $this->widget('zii.widgets.grid.CGridView', array( // ... options ... 'ajaxUpdate'=>true, 'afterAjaxUpdate'=>'aFunctionThatWillBeCalled', // // ... more options ... )); 

You can add the js function as follows:

 Yii::app()->clientScript->registerScript('some-script-id','function aFunctionThatWillBeCalled(id, data){ console.log("id is "+id); // your jquery code to remember checked rows }'); 
+12
source

All Articles