2

I have some anchors in the page and when I load page using anchor:

http://localhost:1820/Home/FAQ#question4

jQuery Mobile after 1-3 seconds automatically scrolls to top of the page. I cannot add fix to $(document).ready() because this event fires before scrolling (scrolling appear after all content is loaded - with additional social button images, scripts etc.).

When I removing jquery.mobile-1.1.1.js script - bug disappears. When I removing all scripts except jQuery and jQuery mobile - bug still exists. So the problem should be in jQuery Mobile script.

How can I solve problem?

I used Chrome and Opera to test it.

P.S. I set $.mobile.ajaxEnabled = false;, so my site do not use Ajax to load pages.

leavelllusion
  • 329
  • 5
  • 11

2 Answers2

1

jQueryMobile uses by default the '#' character to indicate pages, not anchors (see section "Linking within a multi-page document" in the documentation).

Try adding rel="external" or data-ajax="false" to the link to the page, as described in the documentation.

Pablo
  • 2,834
  • 5
  • 25
  • 45
  • This bug appears even if I directly enter URL address to my browser navigation bar, without using links. – leavelllusion Sep 12 '12 at 13:51
  • You will need to give the id "question4" to the `div` with `data-role="page"` that you want to display with the URL. – Pablo Sep 12 '12 at 14:11
1
$.mobile.silentScroll()

Can be a solution to your problems.You can catch the Hash section at page load and use it to automatically scroll to the section where you need to take your page to. I answered a similar question recently. See if it helps you jQuery Mobile Tabs and Anchors

Community
  • 1
  • 1
InspiredBy
  • 4,271
  • 6
  • 40
  • 67