Solve the problem of PHP crashing after paging in Yii's CGridView when there are too many advanced search options_PHP Tutorial

WBOY
Release: 2016-07-14 10:09:43
Original
848 people have browsed it

The reason why reverse redirection PHP crashes is because there are too many options. In fact, empty options do not need to be added to the paging URL.

You can put the following code at the bottom of the views/layouts/main.php file to correct the address of the CGridView paging link.
[html]
Yii::app()->clientScript->registerScript('pagerHref', "
$(function(){
$('.pager a').each(function(){
var href = $(this).attr('href');
var page = href.match(//([w]+)_page/([0-9]+)/);
if (page != null) {
page = page[1]+'_page='+page[2];
} else {
page = '';
} }
var sort = href.match(//([w]+)_sort/([w]+)/);
if (sort != null) {
sort = sort[1]+'_sort='+sort[2];
} else {
sort = '';
} }
var fields = $('.search-form form').serializeArray();
var data = '';
$.each(fields, function(i, field){
if (field.value != '') {
                                                                                                   
data += field.name + '=' + field.value;
        } else {
data += '&' + field.name + '=' + field.value;
        }  
      }  
});
if (data != '' && page != '') {
page = '&' + page;
} }
if ((data != '' || page != '') && sort != '') {
sort = '&' + sort;
} }
var url = '".$this->createUrl($this->id.'/'.$this->action->id)."?' + encodeURI(data) + page + sort;
$(this).attr('href', url);
});
});
");
?>

http://www.bkjia.com/PHPjc/477635.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477635.htmlTechArticleThe crash of reverse php is because there are too many options. In fact, empty options do not need to be added to the paging URL. You can put the following code at the bottom of the views/layouts/main.php file to correct CGridVie...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template