I found some old answers for this, but they do not seem no longer valid for jQuery Mobile.
I want to disable AJAX/hashbang behavior certain links only. I have found out I can disable it globally:
/**
* Supress some jQuery Mobile default behavior
*/
$(window.document).bind("mobileinit", function() {
// https://github.com/mobilizejs/mobilize.js/blob/mas开发者_StackOverflowter/js/mobilize.onjq.js#L51
$.mobile.ajaxEnabled = false;
$.mobile.hashListeningEnabled = false;
});
... but I'd like to disable it for certain classes only, so that my custom click() handlers are not screwed up. Looks like return true or e.preventDefault() in click() do not help this time.
On a link-by-link basis the two main ways of suppressing the default Ajax navigation are to either set a rel=external
attribute, or set any kind of target
attribute.
Given that, you could either update the mark-up of the relevant links, or better, assign the attribute you choose dynamically when your pages are loading.
At some point data-ajax="false"
was introduced.
精彩评论