CListView and CHtml::button not working together with pagination

Not sure if this is a bug or I’m missing something, but it seems strange to me:

If you put a view in a paginated CListView that has a CHtml::button that leads to an url of some sort in it, the urls are not updated when when the next page is loaded:

<?php $this->widget('zii.widgets.CListView', array(



    'enablePagination' => true,

)); ?>

The _view :

$url = '/something/update/id/' . $data->primaryKey;

<?php echo CHtml::button('Edit', array(

       'submit' => $url,

   )); ?>

The output of this is some javascript:

<script type="text/javascript">


jQuery(function($) {


    $('body').on('click','#yt1',function(){jQuery.yii.submitForm(this,'/something/update/id/62',{});return false;});


// ...

    $('body').on('click','#yt10',function(){jQuery.yii.submitForm(this,'/something/update/id/87',{});return false;});




And some html that looks like this:

<input name="yt10" type="button" value="Edit" id="yt1" />

<!-- ... -->

<input name="yt10" type="button" value="Edit" id="yt10" />

Which makes perfect sense. HOWEVER, if you click on one of the links in the pagination area, only the HTML for the new items is fetched (using Ajax), NOT the corresponding JavaScript code. As a result, the first button on the new page will open the same link as the first button on the original page (as it has the same id - yt1).

Is there a "correct" way around this? As far as I can tell CListView does not have an option to disable loading new pages using Ajax. All other solutions I can think of involve writing my own Javascript for the buttons, which is doable, of course, but kind of ugly and un-Yii-like.

Also, it seems to me, but again, I might be missing something, that this behavior is in fact a bug - the original Javascript does not get updated when a user clicks a link in the pagination area of the widget


Did you ever find a solution for your problem? Just came across the same issue. As soon as I move to a new page, the buttons stop working based on the missing Java Script for these buttons.




It works when the property ‘ajaxUpdate’ of CListView is set to false.

But the advantage of ajax loading of pages in CListView is lost.

The ‘submit’ in ‘htmlOptions’ of CHtml::button method registers a Javascript.

I think this is not available in ajax loaded pages. I am not able to figure it out the exact problem.

CHtml::link method works very well as it does not leave any script in normal usages.

I hope some workaround may be there.

A solution is to wrap the view portion you want updated as well in a div with [font="Courier New"]id="something"[/font], and specify that [font="Courier New"]something[/font] as the value of the ajaxUpdate property.

Edit: an answer that has strictly nothing to do with the issue :)

CListView and CGridView javascript code for updating the view extract the content of div specified by their ‘id’ property. In essence, javascript code registered using CClientScript will not be rendered since the code will normally be outside that div.

So you are going to get the old javascript responding to your clicks resulting in the same url.

Try this

Add to CListView ‘ajaxUpdate’=>false,

<?php $this->widget(‘zii.widgets.CListView’, array(




)); ?>

hi friends to hide goto page you can use

&#036;this-&gt;widget('zii.widgets.CListView', array(







Has anyone found a nice solution for this problem? None of the above suggestions have worked for me.