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:success not trigger when go back #689

Open
moonscu opened this issue Nov 11, 2017 · 1 comment
Open

pjax:success not trigger when go back #689

moonscu opened this issue Nov 11, 2017 · 1 comment

Comments

@moonscu
Copy link

moonscu commented Nov 11, 2017

I found that when using the browser to go back, "pjax:success" didn't trigger, causing you to not return to the original height, but to the top of the previous page.
The following code not work:

    var scrollTo = options.scrollTo

    // Ensure browser scrolls to the element referenced by the URL anchor
    if (hash) {
      var name = decodeURIComponent(hash.slice(1))
      var target = document.getElementById(name) || document.getElementsByName(name)[0]
      if (target) scrollTo = $(target).offset().top
    }
@irosadie
Copy link

irosadie commented Feb 8, 2022

$(document).on('pjax:popstate', function(){ //detect goback })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants