I'm trying to close my Phonegap Android app with the following piece of code:
document.addEventListener("backbutton", function () {
if ($('.screenshot').is(":visible")) {
if (confirm('Afsluiten?')){
setTimeout( function() { navigator.app.exitApp(); });
}
else {
'';
}
}
else {
$(".items , .screenshot").show();
$(".content , .openbrowser , .html5vid , .introtekst_gal" ).hide();
$(".terug").hide();
}
}, true);
It works once: Pressing the back-button and then "Ok" closes the app, as expected.
But when I do it like this, the app doesn't close anymore:
- Press back-button (pop up shows)
- Press "cancel" (pop up goes away)
- Press back-button (pop up shows)
- Press "ok" (pop up goes away and app SHOULD close, but doesn't)
What am I doing wrong?