Skip to content

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

Closed
padutilleul opened this Issue Feb 4, 2013 · 5 comments

3 participants

@padutilleul

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(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_view',
    'enableHistory'=>true,
)); ?>

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 :
http://www.mysite.com/controller/index?undefined=

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] || ''));
@mdomba
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
@padutilleul

Sure, I will gladly try to do it :)

@mdomba
Yii Software LLC member
mdomba commented Feb 4, 2013

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

https://github.com/yiisoft/yii/wiki/Git-workflow-for-Yii-contributors

@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…
…leHistory=true
a4decce
@mdomba mdomba closed this Feb 4, 2013
@padutilleul

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

@samdark
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.