Reputation: 2597
After page is loaded i press a link and a particular page is loaded. The problem starts when i want to go back to the index page - the page is "cached". It stays in the DOM with display:none
or something that, but i need that it would load every time as new, how to do this? I already tried:
jQuery.ajaxSetup({cache: false});
jQuery.mobile.ajaxLinksEnabled = false;
data-cache="false"
jQuery.mobile.page.prototype.options.domCache = false;
Upvotes: 0
Views: 186
Reputation: 57309
This feature is still a bit buggy, at least data-cache="false".
To disable cashing on a app level you need to do it in mobileinit event, like this:
$(document).bind("mobileinit", function() {
$.mobile.page.prototype.options.domCache = false;
});
one more thing, a lot of people don't understand this part. Mobileinit event MUST be initialized before jQuery Mobile is initialized, like this:
<script src="jquery.js"></script>
<script>
$(document).bind("mobileinit", function() {
$.mobile.page.prototype.options.domCache = false;
});
</script> <!-- Note your script before jqm -->
<script src="jquery-mobile.js"></script>
Sometimes you don't want to disable page cashing on a app level, in this case data-cache="false" should work, unfortunately it is not working as intended. But it can be forced like this:
$('div').on('pagehide', function(event, ui){
var page = $(event.target);
if(page.attr('data-cache') == 'false'){
page.remove();
};
});
This part of code will remove page after it is hidden.
Here's a live jsFiddle example: http://jsfiddle.net/Gajotres/wgLzu/
Upvotes: 2