Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
qiangxue opened this Issue · 2 comments

3 participants

@qiangxue
Owner

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: http://www.yiiframework.com/demos/blog/index.php/comment/index (try to delete the second element of the second page, you'll see what it actually warns you about to delete).

Migrated from http://code.google.com/p/yii/issues/detail?id=2425


earlier comments

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

set for 1.1.10 milestone

@mdomba mdomba was assigned
@klimov-paul
Collaborator

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


$this->widget('zii.widgets.CListView', array(
    'ajaxUrl'=>array($this->getRoute()),
...
@mdomba mdomba closed this
@mdomba
Collaborator

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
Something went wrong with that request. Please try again.