I am trying to program RSS reader using jquery mobile and cordova. My RSS reader consists of 3 pages (in same HTML document: page1, page2, page3). I am trying to override (h
To disable the default behavior of the back button on android devices simply register an event handler for the back button. This would prevent the back button from closing the application.
Code shown below is specifically for Framework7
$(document).on('page:beforeinit', function (e) {
if( $.fn.hyellaIMenu.mainView.history && $.fn.hyellaIMenu.mainView.history.length > 1 ){
document.addEventListener( "backbutton", disableBackButton, false );
}
});
function disableBackButton( e ){
if( $.fn.hyellaIMenu.mainView.history && $.fn.hyellaIMenu.mainView.history.length < 3 ){
document.removeEventListener("backbutton", disableBackButton );
}
if( $.fn.hyellaIMenu.mainView.history && $.fn.hyellaIMenu.mainView.history.length > 1 ){
$.fn.hyellaIMenu.mainView.router.back();
}
};
To override the default back-button behavior, register an event listener for the backbutton event.
NOTE: It is no longer necessary to call any other method to override the back-button behavior.
https://cordova.apache.org/docs/en/latest/cordova/events/events.html#backbutton