I am writing an app with phonegap and jquery mobile.
For handling unknown errors I need to completely restart my app and reinitialise all variables and dynamic content back to being the equivalent of the first run.
Originally I was just using $.mobile.changePage($'#home') which obviously doesn't work because it doesn't reinitialise any of the dynamic content or variables so I end up with double ups.
Is there a method I can call in jquery mobile to completely restart the app and set everything back to the initial settings?
For a full solution, I think you are out of luck.
iOS definitely will *NOT allow the programatic killing of an app, let alone the programatic starting one.
Android does allow the killing of an app. Though undocumented (that I could find) you can use
navigator.app.exitApp();
to kill the current app.
However, you still cant re-start it programaticly.
I think your best bet will be to write the code to reset the variables and local storage/DB (if used). Then reload the index page via document.location.href = 'index.html?var=xxx';
where xxx = the current timestamp. Placing the timestamp at the end will ensure that it pulls a non-cached version of the page.
*Edit: Added not to my statement about Apple allowing app killing as it should have been.
Try, document.location.href
document.location.href = 'index.html';
Have you tried to reload app?
The reload() method is used to reload the current document.
The reload() method does the same as the reload button in your browser.
By default, the reload() method reloads from the cache, but by you can force the the reload to get the page from server by setting the forceGet parameter to true.
location.reload();
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