1

When I click any of the internal links on a jquery mobile powered site it shows the spinner and tries to load the page via AJAX. I would like to load each page through a full reload instead. I can achieve this by adding this attribute to all links:

data-ajax="false"

But I have a lot of links and would rather not clutter up the HTML by adding these manually. Is there a way I can define it in the JS in one place and have it impact all links site wide?

I tried this but no luck:

$(document).bind("mobileinit", function(){
    $.extend($.mobile, {
        defaultTransition: 'none',
        ajaxEnabled: false,
        ajaxLinksEnabled: false
    });
});

2 Answers 2

3

You can add data-ajax="false" to the containing div to affect all the links. You will need to set ignoreContentEnabled to true in the configurations. This is handy if you have a containing div for the entire page.

See docs http://jquerymobile.com/demos/1.2.0/docs/pages/page-links.html

"In version 1.1, we've added support for using data-ajax="false" on a parent container which allows you to exclude a large number of links from the Ajax navigation system. This avoids the need to add this attribute to every link in a container. To activate this functionality, $.mobile.ignoreContentEnabled must be set to true. Please check Configuring Defaults before using and setting this option."

You can also set the default to not allow any ajax links, that info is here http://jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html see ajaxEnabled

Sign up to request clarification or add additional context in comments.

Comments

1

You could put something like $('a').attr('data-ajax', 'false');.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.