After jQuery mobile pageShow silentscroll, page jumps to top

After jQuery mobile pageShow silentscroll, page jumps to top

Hi!

We have a basket page, where there are the products, and then the shipping methods. This is a jQuery mobile site.

What I want to achive, that if a shipping method selected, then if there is a page reload, jQuery mobile jumps to a div to the shipping methods.

Here is the code, what scrolls to the shipping methods. This is an inline script.


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


Expected result: on page refresh, the window scroll to the #kosar div.


Current result: page scrolls to the #kosar div, but immediatly scroll to the top of the page.


What we discovered, if some error is occures after the silentScroll, the window is not jump back to the top of the page. So it seems, something after the pageshow scrolls it to back, but we do not know, what.


For example:


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


Here are the non working, and "working" examples:

Here is a live example. When you refresh the page, you will see for a second the big red text, and immediatly after that you will be taken to the top of the page.


Here is the example with error.


I've tested it in FF Developer Edition. With Chrome, you need to resize your browser to a littlebit smaller, and refresh some times to see the scrollbar how jumping to bottom and up.

How can I prevent this annoying scroll to top?

(In the example there could be differenc, for example, div is a link (a tag), but it does not matter).