javascript - jQuery Mobile - Android Back button prompt confirmation -
i have jquery mobile app (about 7 html pages). want change button functionality in android (using eclipse phonegap). tried @overwrride won't work properly.
i on every page, when button hit, prompt: "are sure want exit?" yes , no options.
now have script exits app completely.
<script type="text/javascript"> document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() { document.addeventlistener("backbutton", onbackkeydown, false); } function onbackkeydown() { navigator.app.exitapp(); } </script> is there way have inside function onbackkeydown() jquery window popup , have if condition, click yes execute navigator.app.exitapp(); or cancel if hit no?
i new this, appreciate help!
thanks.
if understand question right, :
document.addeventlistener("deviceready", ondeviceready, false); function ondeviceready() { document.addeventlistener("backbutton", onbackkeydown, false); //listen user clicking on button } function onbackkeydown(e) { e.preventdefault(); navigator.notification.confirm("are sure want exit ?", onconfirm, "confirmation", "yes,no"); // prompt user choice } function onconfirm(button) { if(button==2){ //if user selected no, nothing return; }else{ navigator.app.exitapp(); // otherwise quit app. } }
Comments
Post a Comment