Which event to catch for application shut down?
- by xueru
I am using jQueryMobile and phoneGap for a cross-device mobile application. I use html 5 local storage to persist records that worked on by user.
I don't know which phoneGap event to catch just before application shut-down so I can make sure data is saved before shutdown completes.
Base on suggestion from naughtur, I tried both unload and beforeunload events, neither of them got fired during app shutdown. Following is my code snip:
function persistTasks(){
alert ("is unloading the app");
offlineTasklist.set("tasks", tasklist);
}
function init() {
document.addEventListener("unload", persistTasks, false);
login();
}
$(document).ready(init);