leavelllusion
leavelllusion

Reputation: 329

How to disable jQuery Mobile scrolling to top of the page?

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.

Upvotes: 2

Views: 3510

Answers (2)

InspiredBy
InspiredBy

Reputation: 4320

$.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

Upvotes: 1

Pablo
Pablo

Reputation: 2854

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.

Upvotes: 1

Related Questions