When add to link options data-method and data-pjax
Html::a(
'<i class="fa fa-minus"></i>',
Url::to(['/admin/roles/revoke', 'roleName' => $roleName, 'permissionName' => $model['name']]),
[
'data-method' => 'post',
'data-pjax' => 1,
]
);
inside pjax container, after request to server, pjax scroll page to top.
If add ['data-pjax-scrollto' => true] page does not scroll. :)
No scroll page after request.
pjax scroll page to top.
In yii.js row 170-180 need replace
pjaxOptions = {
container: pjaxContainer,
push: !!$e.data('pjax-push-state'),
replace: !!$e.data('pjax-replace-state'),
scrollTo: $e.data('pjax-scrollto'),
pushRedirect: $e.data('pjax-push-redirect'),
replaceRedirect: $e.data('pjax-replace-redirect'),
skipOuterContainers: $e.data('pjax-skip-outer-containers'),
timeout: $e.data('pjax-timeout'),
originalEvent: event,
originalTarget: $e
};
with
pjaxOptions = {
container: pjaxContainer,
push: !!$e.data('pjax-push-state'),
replace: !!$e.data('pjax-replace-state'),
scrollTo: $e.data('pjax-scrollto') !== undefined ? $e.data('pjax-scrollto') : false,
pushRedirect: $e.data('pjax-push-redirect'),
replaceRedirect: $e.data('pjax-replace-redirect'),
skipOuterContainers: $e.data('pjax-skip-outer-containers'),
timeout: $e.data('pjax-timeout'),
originalEvent: event,
originalTarget: $e
};
| Q | A
| ---------------- | ---
| Yii version | 2.0.11.2
| PHP version | 7.0.13|
| Operating system | windows/linux
Got same problem on Max OS X (not surprising).
Work around for me: set global Pjax default scrollTo option to false in view file, like this:
$this->registerJs('$.pjax.defaults.scrollTo = false;', \yii\web\View::POS_LOAD);
I'm sorry to inform you that the core team has decided to stop with the support of PJAX. This implies that we are not accepting PR's for updating PJAX in the 2.0.x branch anymore. In the 2.1 branch it will be removed from the framework.
A lot has been said on this subject. Our conclusion is that the current state of PJAX does not meet our standards to properly support in the Yii framework. For this reason, we are also not moving it into a Yii2 extension. Of course the Community is free to fill this gap, but with a warning. It is very time consuming to support and in our humble opinion, it should be completely rewritten to properly meet the many usecases developers have with it.