The first thing we need to do is include "Pjax" itself:
use yiiwidgetsPjax;
Next, wrap the desired content in the Pjax widget. For example:
<?php Pjax::begin([ 'id' => 'pjaxContent' ]); ?> Content here <?php Pjax::end(); ?>
And to forcefully reload the desired content, run the following JavaScript code:
$.pjax.reload({container: '#pjaxContent'});Don’t forget that the jQuery framework must be included (in Yii, it comes by default).
Or bind the reload to an event:
$(document).on('click', '#myBtn', function (e) {
e.preventDefault();
$.pjax.reload({container: '#pjaxContent'});
return false;
});