Toma Tomov
Toma Tomov

Reputation: 1674

Using Pjax for LinkPager in Yii2

I am trying to use Pjax with LinkPager in my project, but it doesn't work.

When I try to switch to the second page of my list the browser reloads.

Am I using it wrong?

This is my view:

<?php \yii\widgets\Pjax::begin() ?>
<!-- Book List Widgets -->
<div id="filter-masonry" class="gallery-masonry">
<?php
    if($bookModels){
        foreach ($bookModels as $book){
            $book = Product::find()->where(['id' => $book['product_id']])->one();

            echo $this->render('_multiViewBooks', [
                               'book' => $book,
                               'lang' => $lang,
                               'authorPage' => $authorsPage,
                               'bookPage' => $bookPage,
                               'genrePage' => $genrePage
                                ]);
        }
    }
?>
</div>
<?php
    echo "<div class='pagination-holder'>";
    echo LinkPager::widget([
                   'pagination' => $pagination,
                   'hideOnSinglePage' => true,
                   'prevPageLabel' => 'Prev',
                   'nextPageLabel' => 'Next'
                  ]);
    echo "</div>";
?>
<?php \yii\widgets\Pjax::end() ?>

Everything between the Pjax tags should be reloaded without whole page reload, am I right?

Upvotes: 1

Views: 936

Answers (1)

Yerke
Yerke

Reputation: 2215

Everything should work fine. Maybe you Pjax tooks too long to refresh, so it reloads the whole page after timeout?

Try to increase timeout parameter

Pjax::begin(['timeout' => 5000 ]);

of Pjax widget and check it once again.

Upvotes: 3

Related Questions