FavorMylikes
FavorMylikes

Reputation: 1222

How to run the js code of widget in gridview cell after filter?

I'm using Yii 1.x framework.I have a booster TbGridView table,in some cell I added some widget like select2 and datetimepicker to make it more practical and look better,at the same time I also added a filter at the top of the table.But after used filter,I found the js code that initialize widget not to be used.In HTML code that had generated I found the js code was added at the bottom of page,when I used filter,it's just fresh the table with ajax,so the js code at the bottom was not be used.So,what's the solution at this time.Anybody can help me?please.

Upvotes: 0

Views: 136

Answers (2)

Tiến Nguyễn
Tiến Nguyễn

Reputation: 26

You can use afterAjaxUpdate.

$this->widget('zii.widgets.grid.CGridView', array(
    'afterAjaxUpdate' => 'reinstallDatePicker',
    ...
);

Yii::app()->clientScript->registerScript('re-install-date-picker', "function reinstallDatePicker(id, data) {}");

http://www.yiiframework.com/wiki/318/using-cjuidatepicker-for-cgridview-filter/

Upvotes: 1

peaceman
peaceman

Reputation: 1721

I'm just thinking out loud... since you can listen for ajax requests (ajaxStart, ajaxStop) can you call that widget on ajaxStop.

Upvotes: 0

Related Questions