I am using jQuery Mobile 1.1.1 and Apache Cordova 2.0.0. I want my app to exit when I press back button but only if current page have ID = feedZive. I am using following code to do it:
function onDeviceReady(){
document.addEventListener("backbutton", onBackKeyDown, false);
function onBackKeyDown(){
if ($.mobile.activePage.is("#feedZive")){
navigator.app.exitApp();
}
else{
navigator.app.backHistory();
}
}
};
However it looks like I can’t get the current page because I have tried the following code:
var activePage = $.mobile.activePage;
alert(activePage);
and my alert is showing undefined. I have also tried to change $.mobile.activePage to $.mobile.activePage.attr("id") but it didn’t work.
http://jsfiddle.net/ajD6w/5/