【问题标题】:cakephp 3.x ajax paginationcakephp 3.x ajax 分页
【发布时间】:2016-12-29 00:37:42
【问题描述】:

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

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

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

$this->Js->writeBuffer();

请有人帮助我。

【问题讨论】:

标签: ajax cakephp pagination


【解决方案1】:

我已经使用下面的脚本完成了 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;
    });

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-09
    • 2016-01-02
    • 2015-05-10
    • 2015-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多