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