i hae my app sofar working. there are several pages which were loaded via ajax. after some time i need to delete doese loaded pages. the loaded pages have dom-cache enabled, as during the initual/normal use of the app it is ok to cache the pages and not load them with every request.
i tried to do something like:
1) set cookie on deviceready with startingTime
2) onResume: check startingTime and when it is over timeout i will have to do the cleaning
3) changePage to homepage is working
4) deleting pages is not working!!!!
step 4 is where i am stuck now.
- var timeElapsed = 0;
document.addEventListener("resume", onResume, false);
function onResume() {
setTimeout(function() {
var jetzt = new Date();
var startupTime = $.cookie('startupTime');
if (startupTime) {
var elapsed = jetzt.getTime() - startupTime; /* in ms */
var minuten = elapsed / ( 1000 * 60);
console.log('min: ' + minuten);
if (minuten > 2) {
$.cookie('startupTime', jetzt.getTime(), { expires: 1 });
$.mobile.changePage($("#homepage"), {changeHash: true});
timeElapsed = 1;
}
} else {
console.log('resume: NULL');
$.cookie('startupTime', jetzt.getTime(), { expires: 1 });
}
}, 0);
}
so this is working. i tried
- $("div:jqmData(role='page')").each( function() {
console.log('remove: ' + $(this).attr('id') + ' ' + $(this).attr('data-external-page')); - $(this).remove()
});
but this is not working really well. at the end i get a bland white screen in my app. you can i delete the state of the app? i tried to move the removing to the page-show event, but this also does not work.
when i use the remove in a web-only-version it seems to work.
i now tried:
- if (minuten > 2) {
$.cookie('startupTime', jetzt.getTime(), { expires: 1 });
$.mobile.changePage($("#homepage"), {changeHash: true});
setTimeout(function() {
$("div:jqmData(role='page')").each( function() {
if ($(this).attr('data-external-page')) {
console.log('remove: ' + $(this).attr('id'));
$(this).remove();
}
});
}, 1000);
}
this seems to work. the homepage is loaded, i can see in the xcode console.log that the pages are removed (at least i see the message). but then i can't click on the links on homepage. they get highlighted but no pagechange is triggered?