Tags » JQuery Mobile

Back button handler in jQuery Mobile & PhoneGap

var pageHistoryCount = 0;
var goingBack = false;

$(document).bind("pageshow", function(e, data) {
    if (goingBack) {
        goingBack = false;
    } else {
        pageHistoryCount++;
        console.log("Showing page #"+pageHistoryCount);
    }
});

function exitApp() {
    console.log("Exiting app");
    navigator.app.exitApp();
}

function onPressBack(e) {
    e.preventDefault();
    if(pageHistoryCount > 0) pageHistoryCount--;
    if (pageHistoryCount == 0) {

        navigator.notification.confirm("Are you sure you want to quit?", function(result){
            if(result == 2){
                exitApp();
            }else{
                pageHistoryCount++;
            }
        }, 'Quit My App', 'Cancel,Ok');
    } else {
        goingBack = true;
        console.log("Going back to page #"+pageHistoryCount);
        window.history.back();
    }
}

function deviceready() {
    $(document).bind('backbutton', onPressBack);
}
$(document).bind('deviceready', deviceready);
Development

jQuery Mobile Training Course in Hyderabad India UK

jQuery Mobile Training Online

jQuery Mobile Training Course Duration: 25-35hrs jQuery Mobile Training Course Fee: $ jQuery Mobile Training Pre-Requisites: 
JQuery Course Contents

Add an Exit Menu to Mobile app built in PhoneGap and jQuery Mobile

To add an exit menu when the back button is pressed is very straight forward, all we need to  do is to add a listener for the “ 100 more words

Development

jQuery Mobile - What's it

What is it?

jQuery Mobile is a touch-optimized HTML5 based web framework designed to make responsive web sites and apps that are accessible on all smartphones, tablets and desktop devices. 25 more words

JQuery Mobile