Skip to content
This repository

pjax scrolls to top by default #133

Closed
staabm opened this Issue · 11 comments

7 participants

Markus Staab Joshua Peek Joshua Sierles Nathan L Smith Daniel Marino Rohit Joshi rjquery
Markus Staab

is it intended behaviour, that on each pjax request the browser scrolls to top?

the reason for this is that scrollTo defaults to 0 instead of false


pjax.defaults = {
  timeout: 650,
  push: true,
  replace: false,
  type: 'GET',
  dataType: 'html',
  scrollTo: 0,
  maxCacheLength: 20
}

Markus Staab staabm referenced this issue in redaxo/redaxo
Closed

pjax: timeout message #60

Joshua Peek josh closed this
Joshua Peek
Collaborator
josh commented

Yes, set $.pjax.defaults = false to turn it off.

Joshua Sierles

This should read:

$.pjax.defaults.scrollTo = false;
Nathan L Smith

Not sure if it's a bug, but for me, $.pjax.defaults is undefined in IE (<= 9). Was able to work around with $.pjax.defaults = $.pjax.defaults || {}; $.pjax.defaults.scrollTo = false;. Should an issue be opened for this?

Joshua Peek
Collaborator
josh commented

pjax requires >= IE 10

Nathan L Smith

Understood. Is it expected to fail gracefully in earlier versions?

Joshua Peek
Collaborator
josh commented

You can use the $.support.pjax to condition your custom pjax code to not run on oldIE

Daniel Marino

Just because it requires a certain browser... I think it should at least fail gracefully

Nathan L Smith

@josh Thanks that helps. @starzonmyarmz It does fail gracefully, but if you try to set $.pjax.defaults values, you'll want to wrap it in an if ($.support.pjax).

Daniel Marino

gotcha - thanks for clarifying

Rohit Joshi

thanks for
$.pjax.defaults.scrollTo = false

rjquery

thanks for $.pjax.defaults.scrollTo = false;!!!! [2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.