gannher
gannher

Reputation: 25

Cakephp 2.8 Pagination link number not clickable

First sorry for my english.

I'm trying to use pagination with ajax with cakePHP 2.8.3.

The first load works good. I see the paginator number :

Paginator numbers is load

When I click on page number "2" or on "Next >>", the content #content-recherche is refresh but the link page number 1 (and link "<< Previous") is not usable. The page number "2" stay clickable ...

Here my code in controller :

Public variable for pagination :

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

The code inside my action:

$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);

My code in view:

<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>

Someone see what is my error ?

Thanks.

Upvotes: 0

Views: 141

Answers (1)

user3082321
user3082321

Reputation: 654

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

You are not updating/refreshing code in <ul class="pagination"></ul>. You have to refresh/update code in <ul class="pagination"></ul> tag as well when you refresh/update content in <div id="content-recherche"></div> block.

Upvotes: 3

Related Questions