2016-08-22 79 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; 
    }); 

});