Hi!
I’m using pjax for erasing values of my gridview. But after the request the page always scrolls to top. That’s annoying…
After a little research, I discovered I could overcome the problem with
$.pjax.defaults.scrollTo = false;
.
Why the Yii Pjax Widget (yii\widgets\Pjax) has the ‘scrollTo’ default value = false and in jquery.pjax.js the defaults are definied with ‘scrollTo: 0’?
In jquery.pjax.js (around line 920):
// Install pjax functions on $.pjax to enable pushState behavior.
//
// Does nothing if already enabled.
//
// Examples
//
// $.pjax.enable()
//
// Returns nothing.
function enable() {
$.fn.pjax = fnPjax
$.pjax = pjax
$.pjax.enable = $.noop
$.pjax.disable = disable
$.pjax.click = handleClick
$.pjax.submit = handleSubmit
$.pjax.reload = pjaxReload
$.pjax.defaults = {
history: true,
cache: true,
timeout: 650,
push: true,
replace: false,
type: 'GET',
dataType: 'html',
scrollTo: 0, <----- HERE
maxCacheLength: 20,
version: findVersion,
pushRedirect: false,
replaceRedirect: true,
skipOuterContainers: false,
ieRedirectCompatibility: true
}
$(window).on('popstate.pjax', onPjaxPopstate)
}
Thanks in advance!