0

首先对不起我的英语。

我正在尝试在 cakePHP 2.8.3 中使用带有 ajax 的分页。

第一次加载效果很好。我看到分页器号码:

分页器编号已加载

当我单击页码“2”或“Next >>”时,内容 #content-recherche会刷新,但链接页码 1(和链接“<< Previous”)不可用。页码“2”保持可点击...

这是我在控制器中的代码:

分页的公共变量:

public $paginate = array('Entite' => array(
        'limit' => 2,
        'order' => array(
            'Entite.nom' => 'asc'
        ),
));

我的操作中的代码:

$this->Paginator->settings = $this->paginate;
    $this->Paginator->settings = array(
        'conditions' => $conditions,
        //'limit' => $sql_limit
        'limit' => 2
    );
$data = $this->Paginator->paginate('Entite');
    $this->set('data', $data);

我的代码在视图中:

<div id="content-recherche">
...
</div>
<ul class="pagination">
    <?php
    $this->Js->JqueryEngine->jQueryObject = 'jQuery';

    $this->Paginator->options(array(
        'update' => '#content-recherche',
        'url' => array('controller' => 'Recherche', 'action' => 'coiffure'),
        'complete' => '$.getScript("/js/utils.js", function (data, textStatus, jqxhr) {});',
        'evalScripts' => true,
    ));
    ?>

    <?php
    echo $this->Paginator->numbers(array(
        'first' => '<<',
        'currentClass ' => 'active',
        'tag' => 'li',
        'modulus' => 5,
        'last' => '>>'));
    ?>
    <?php
    echo $this->Paginator->prev(
            '« Previous', null, null, array('class' => 'disabled')
    );
    echo $this->Paginator->next(
            'Next »', null, null, array('class' => 'disabled')
    );
    ?>

</ul>

有人看到我的错误是什么?

谢谢。

4

1 回答 1

3
<div id="content-recherche">
...
</div>
<ul class="pagination">
...
</ul>

您没有更新/刷新<ul class="pagination"></ul>. <ul class="pagination"></ul>当您刷新/更新块中的内容时,您还必须刷新/更新标签中的代码<div id="content-recherche"></div>

于 2016-08-23T03:53:59.413 回答