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 != '') {
if (data == '') {
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.htmlTechArticle倒导php崩溃是因为选项过多,其实为空的选项可以不用添加到分页的url上。 可以将以下代码放到views/layouts/main.php文件的底部,修正CGridVie...