Yii CGridView javascript 分页事件 [英] Yii CGridView javascript event on pagination

查看:21
本文介绍了Yii CGridView javascript 分页事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Yii 中使用 jQuery 扩展 CGridView 以在切换页面时记住选中的行.页面是使用 AJAX 加载的,所以我认为当请求完成并呈现新页面时,我希望我的代码能够发挥作用.但是,我似乎无法找到任何说明在新页面完成渲染时触发任何事件的文档.

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.

不过,我可以使用 DOM 侦听器,但我认为对整个页面使用一个事件会更好.

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

推荐答案

您可以使用 afterAjaxUpdate(因为你的页面加载了ajax):

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 ...
));

你可以像这样添加js函数:

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
}');

这篇关于Yii CGridView javascript 分页事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆