Hi,
I tried a lot but unable to implement back button code in v2.
When user is on ‘index.html’ or ‘dashboard.html’ page. If user press on back button, he should exit from app with confirmation dialog otherwise navigate to previous page.
I have phonegap code for back button but unable to understand where and how to implement this.
Please help. I really need this.
Previously I was able to do in v1 with below code:
document.addEventListener("deviceready", appReady, false);
function appReady(){
document.addEventListener("backbutton", function(e){
var page = getCurrentView(app);
app.dialog.alert(page);
if(page.name=="index"){
navigator.notification.confirm("Are you sure want to exit?", onConfirmExit, "My Project", "Yes,No");
}
else{
navigator.app.backHistory();
}
}
function onConfirmExit(button){
if(button==1){
navigator.app.exitApp();
}
else{
return;
}
}