Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pjax scroll #13771

Closed
muratymt opened this issue Mar 14, 2017 · 2 comments
Closed

pjax scroll #13771

muratymt opened this issue Mar 14, 2017 · 2 comments
Assignees
Labels
feature:pjax JS JavaScript related type:bug Bug

Comments

@muratymt
Copy link

What steps will reproduce the problem?

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. :)

What is the expected result?

No scroll page after request.

What do you get instead?

pjax scroll page to top.

Decission

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

Additional info

Q A
Yii version 2.0.11.2
PHP version 7.0.13
Operating system windows/linux
@samdark samdark added feature:pjax type:bug Bug JS JavaScript related labels Mar 14, 2017
@samdark samdark added this to the 2.0.13 milestone Mar 14, 2017
@arogachev arogachev self-assigned this Mar 15, 2017
@squio
Copy link
Contributor

squio commented Mar 15, 2017

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

@cebe cebe modified the milestones: 2.0.x, 2.0.13 Jul 10, 2017
@dynasource
Copy link
Member

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.

@cebe cebe removed this from the 2.0.x milestone Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:pjax JS JavaScript related type:bug Bug
Projects
None yet
Development

No branches or pull requests

6 participants