Pjax is a widget that integrates the pjax jQuery plugin. All content that is wrapped by this widget will be reloaded by AJAX without refreshing the current page. The widget also uses the HTML5 History API to change the current URL in your browser's address line.
Create a new application by using composer, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
In the following example, you can see how you use Pjax with the yii\grid\GridView
widget:
<?php use yii\widgets\Pjax; ?> <?php Pjax::begin(); ?> <?= GridView::widget([...]); ?> <?php Pjax::end(); ?>
Just wrap any code fragment in the Pjax::begin()
and Pjax::end()
calls.
This will render the following HTML code:
<div id="w1"> <div id="w2" class="grid-view">...</div> </div> <script type="text/javascript">jQuery(document).ready(function () { jQuery(document).pjax("#w1 a", "#w1"...