Skip to content

"undefined" parameter in query string when using CListView with enableHistory #2078

padutilleul opened this Issue Feb 4, 2013 · 5 comments

3 participants


How to reproduce :
1/ Create a model and a CRUD controller using Gii
2/ Create enough model instances to activate pagination
3/ set enableHistory to true in the associated index.php view file :

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

Now, if you go to page 2, refresh the page in your browser (important), then click on the page 1 button in the pager, your url should look like :

The problem seems to come from the jquery.yiilistview.js file, line 36-37 :

var url = $(this).attr('href').split('?'),
     params = $.deparam.querystring('?'+ url[1]);

As there is no query string in the ajax request made to load page 1, url[1] is undefined and a "undefined" key is created into the "params" array (with a empty value), which then cause "undefined" to appear in the url.

One simple fix may be to change line 37 for :

     params = $.deparam.querystring('?'+ (url[1] || ''));
Yii Software LLC member
mdomba commented Feb 4, 2013

Confirmed... the same fix should be applied to jquery.yiigridview.js

Would you like to try to create a PR ?

@mdomba mdomba was assigned Feb 4, 2013

Sure, I will gladly try to do it :)

Yii Software LLC member
mdomba commented Feb 4, 2013

Just follow the guidelines... and if needed feel free to ask for help...

@padutilleul padutilleul added a commit to padutilleul/yii that referenced this issue Feb 4, 2013
@padutilleul padutilleul Fix query string problem #2078 with CListView and CGridView when enab…
@mdomba mdomba closed this Feb 4, 2013

Ok, done.
Thank you for pointing me to the guidelines, they were very well written and easy to follow :)

Yii Software LLC member
samdark commented Feb 4, 2013

Thanks for contribution.

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.