2016-08-22 83 views
-1

如何以cakephp方式在cakephp 3.x中实现ajax分页。cakephp 3.x ajax分页

cakephp 2.x,我用下面的代码来实现ajax分页(JS助手)。

$this->Paginator->options(array('update' => '#content', 'evalScripts' => true)); 

$this->Js->writeBuffer(); 

PL帮助我的人。

+0

以下是带有代码的实例:http://sandbox.dereuromark.de/sandbox/ajax-examples – mark

回答

0

我已经使用下面的脚本完成了ajax分页。在你的ctp文件的末尾添加这个脚本。

$(document).ready(function() { 
$(".pagination a").bind("click", function (event) { 
    if(!$(this).attr('href')) 
     return false; 
    $.ajax({ 
     dataType:"html", 
     evalScripts:true, 
     success:function (data, textStatus) {$("#content").html(data);}, 
     url:$(this).attr('href')}); 
     return false; 
    }); 

});