juiWidget in CListView with ajax pagination

Hi i wanted to use a CListView where i wanted some JuiWidget in the itemView in my case i wanted to use


So i added

    $this->widget('zii.widgets.jui.CJuiAccordion', array(


        'test'=>'some text',









And the CJuiAccordion works in the first page. But after a Pagination the it doesn’t.

If looked in firebug an see that the rendered id’s after pagination is starting again with #yw0 which is used from the normal rendering.

So i added some id to get some unique id which is not used.


So my genrated ajax code create some unique id’s. But again the js code after an ajax pagination isn’t executed.

So i thought of adding a css class to the accordions code


and add some code to the Listview to renew the accordions after each ajax request.

 'afterAjaxUpdate'=>"function (id,data) {



And hooray the accordions are working after an ajax request.

But now my question is there some ‘better’ solution for this?

why isn’t the js code which is used in the clistview and therefore must have some relation to it not executed after an ajax request automaticly?

regards Horizons

As a workaround for a similar issue, i.e. paginated item views requiring client side functions on each item, I used this method:

Yii::app()->clientScript->registerScript('script', <<<JS

  function addJSFunctions(){ 

       //the script here can add functions to individual items

       //such as (instead of accordion plugin)



               if ($(this).siblings(".itembody").is(":hidden")){






         //or to add a generic function or process






      , CClientScript::POS_READY);

//Then as you did above add the afterAjaxUpdate function:


'afterAjaxUpdate' => 'function (id,data) {




So every time a new page is called these functions are performed on the new items .