Using jQuery Mobile I would like to disable the ajax call on links within a specific part of the DOM.
I do not want to put a
data-ajax = false
every time I don't want to use the jquerymobile ajax.
For example, any link that is a child of 'content':
<div class="content">
<a href="http://externalwebsite.com">External Link</a>
</div>
I would like to add the 'data-ajax = false' onto every link that is a child of 'content'
Is there a way to do this with jquery?
If you want to disable the ajax link behaviour from an anchor tag, you can put rel=external
in the link and the link will load without ajax and your url will then be usual.
http://jquerymobile.com/demos/1.0a4.1/#docs/pages/docs-navmodel.html
<a href="User/somepage" rel="external" />I wont be using ajax for navigation</a>
If you want to do this in jQuery for some a tags inside content div, you may try like this
$(function(){
$(".content a").each(function(){
$(this).attr("rel","external");
});
});
Here is a sample http://jsfiddle.net/4WEBk/3/
The more Simplified version. (Thanks to tandu for pointing )
$(function(){
$(".content a").attr("rel","external");
});
$(".content a").attr('data-ajax', false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With