after jQuery mobile pageShow silentscroll, page jumps to top -


we have basket page, there products, , shipping methods. jquery mobile site.

what want achive, if shipping method selected, if there page reload, jquery mobile jumps div shipping methods.

here code, scrolls shipping methods. inline script.

$(document).on("pageshow", function (e, ui) {     $.mobile.silentscroll($('#kosar').offset().top); }); 

expected result: on page refresh, window scroll #kosar div.

current result: page scrolls #kosar div, immediatly scroll top of page.

what discovered, if error occures after silentscroll, window not jump top of page. seems, after pageshow scrolls back, not know, what.

for example:

$(document).on("pageshow", function (e, ui) {     $.mobile.silentscroll($('#kosar').offset().top);     undefined_function(); //this function not exists }); 

here non working, , "working" examples:

here live example. when refresh page, see second big red text, , immediatly after taken top of page.

here example error.

i've tested in ff developer edition. chrome, need resize browser littlebit smaller, , refresh times see scrollbar how jumping bottom , up.

how can prevent annoying scroll top?

i think, bug in jquery mobile js, i've reported them.

finally figured out.

version: http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js

i've made breakpoint in jquery mobile js silentscroll definition, , i've see, reason run twice. first call, ypos number, want jump, why jump right place.

but, later, @ line 15432 here these lines of codes, running on document ready:

// window load event // hide ios browser chrome on load if hideurlbar true fall incase before if ( $.mobile.hideurlbar ) {     $window.load( $.mobile.silentscroll ); } 

and when it's happens, on second call, ypos silentscroll object, not number, function expects, , if not number, jquery mobile set ypos $.mobile.defaulthomescroll 1 if not modified. why jumps home.

warning: if think, need set $.mobile.hideurlbar false, wrong. i've tried it, had side effects, because in line 15416 there reference variable, , if turn off, when go page another, wont redirected top of second page.

so solution comment out $window.load( $.mobile.silentscroll ); , working expected.


Comments