Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I refresh a Yii CGridView from js?

Tags:

jquery

php

yii

When a "Create" modal dialog is submitted via XHR Then the rows in a Yii CGridView should be refreshed.

I've tried to achieve this by rendering the new gridview in the XHR "create" action and then inserting it into the page via $("#list").html(response), but rendering a CGridView causes jQuery <script> include tags to be registered for inclusion, and so when I introduce those tags into the page they reload jQuery, which wipes out my live event handlers, so a bunch of stuff breaks.

Which has me thinking, "the GridView knows how to refresh itself. heck, it does all the time on sort or page."

So I can click a sort button in the GridView from js, but thats less than Ideal. I'd prefer to say

$("#list").gridview('reload') or $.fn.gridview.reload("#list") or some such sense.

Or do the way cool thing that is soo much simpler that you thought of just now.

like image 695
Brian Dunn Avatar asked Jun 17 '10 22:06

Brian Dunn


1 Answers

Execute $.fn.yiiGridView.update("<id of CGridView>");

like image 81
jfd Avatar answered Nov 14 '22 02:11

jfd