I am trying to close the Android Phonegap application with the following code snippet:
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 and OK button closes the application as expected.
But when I do it like this, the application no longer closes:
- Click the back button (pop-ups)
- Click cancel (popup disappears)
- Click the back button (pop-ups)
- Click "ok" (the popup disappears and the application MUST close, but does not)
What am I doing wrong?
source share