最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Yii CGridView javascript event on pagination - Stack Overflow

matteradmin3PV0评论

I am extending CGridView in Yii using jQuery to remember the checked rows when switching pages. The pages are loaded using AJAX, so i thought that when the request is finished and the new page is rendered, i want my code to step in an do it's magic. However, i can't seem to find any documentation that indicates any event being fired or so when the new page is finished rendering.

I could however use DOM listeners but i figured it would be better to use one event for the whole page.

I am extending CGridView in Yii using jQuery to remember the checked rows when switching pages. The pages are loaded using AJAX, so i thought that when the request is finished and the new page is rendered, i want my code to step in an do it's magic. However, i can't seem to find any documentation that indicates any event being fired or so when the new page is finished rendering.

I could however use DOM listeners but i figured it would be better to use one event for the whole page.

Share Improve this question asked Feb 12, 2013 at 17:34 Anton GildebrandAnton Gildebrand 3,71713 gold badges52 silver badges92 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 13

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

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

You can add the js function like so:

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

comment list (0)

  1. No comments so far