My current project involves developing Mobile Apps using PhoneGap (Cordova 2.2), JQuery, and Javascript. The landing page is the Login Page. However, after successfully logging in and reaching the Dashboard Page, pressing the BACK BUTTON redirects me back to the login page instead of staying on the dashboard. Any suggestions on how to fix this issue would be greatly appreciated.
I have attempted the following:
SCRIPT
<head>
<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when Cordova is loaded.
//
// At this point, the document has loaded but cordova-2.2.0.js has not.
// When Cordova is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to call Cordova methods
//
function onDeviceReady() {
// Register the event listener
document.addEventListener("backbutton", onBackKeyDown, false);
}
// Handle the back button
//
function onBackKeyDown() {
alert("Back Button Clicked"); //called the alert..checking
}
</script>
HTML
<body onload="onLoad()">
</body>
For some reason, my onDeviceReady and onBackKeyDown functions are not being triggered. Could I be overlooking something???