hi I have some jQuery Mobile and pageshow
works fine (it's blip bugged but it works fine) like this:
$(document).off('pageshow').on('pageshow', function () {
console.log('it happened');
});
NB: I have had numerous (READ: weeks lost) problems with caching, so I am afraid despite all information to the contrary the off()
has to stay. You will argue with me, I will keep off()
and I will be right.
ok but when I change it to
$(document).off('pagebeforeshow').on('pagebeforeshow', function () {
console.log('it happened');
});
it doesn't run. Now I know that you are supposed to be doing something like
$(document).off('pagebeforeshow').on('pagebeforeshow', '#somediv', function () {
console.log('it happened');
});
but I don't want it to be on just that div I want it to be on the whole document.
You can test when you leave a specific page like this ( worked in my case ):
--> Start a loop function ( setInterval ) that tests every 2 sec if you are still on that page, and if not ( it means that you just left the page ) execute only once a function
Here is the code: