CListView + pagintation, ajax request isn't sync. #148

qiangxue opened this Issue Feb 15, 2012 · 2 comments


3 participants

qiangxue commented Feb 15, 2012

What steps will reproduce the problem?

  1. Render a model with CListView with ajax pagination enabled
  2. Create items enough to make it paginate
  3. Go to a non-first page and do some ajax action (i.e. clicking a linkButton to delete the current registry)

What is the expected output? What do you see instead?
Clicking the first item of the 2nd page to won't do anything aside from reloading the page as if it would be doing something.
Clicking the second item of that same 2nd page would ask you to delete the second item of the first page, see?

What version of the product are you using? On what operating system?
latest yii-1.1.7.r3135

Please provide any additional information below.
I think client script is not getting updated on page change, so javascript stills targeting click events for old DOM elements; or javascript executes functions with references to old models. As when click an element of a non-1st page and is treated like you were.
This very same is happening on the blog demo: (try to delete the second element of the second page, you'll see what it actually warns you about to delete).

Migrated from

earlier comments

qiang.xue said, at 2012-01-01T03:36:54.000Z:

set for 1.1.10 milestone

mdomba was assigned Mar 9, 2012


klimov-paul commented Jun 14, 2012

Try to setup "CListView::ajaxUrl" with the base URL for your listing page.
For example:

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

mdomba closed this Jul 27, 2012


mdomba commented Jul 27, 2012

There are few problems here but the main problem is that linkButton is not suitable to be used with CListView as it generates JS code for every comment so instead of having one JS handler for all delete links/buttons it renders one handler for every comment like:

$('body').delegate('#yt0','click',function(){...);return false;});
$('body').delegate('#yt1','click',function(){...);return false;});
$('body').delegate('#yt2','click',function(){...);return false;});

When pagination was used e.g. going to the second page, the JS generated for that page was not run, but the initial JS code was still in effect and as the links IDs are generated automatically the second page links did get the same IDs as the links on the first page... That's why the comments deleted where from the first page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment