I'm aware of the following questions that relate to this, but do not solve the problem I face.
Here is my code in index.html:
ons.ready(function () {
ons.disableDeviceBackButtonHandler();
appnavigator.getDeviceBackButtonHandler().disable();
window.document.addEventListener('backbutton', function (event) {
if (appnavigator.getPages().length > 1) {
event.preventDefault();
appnavigator.popPage();
console.log('Popped a page and now we have', appnavigator.getPages().length, 'pages');
} else {
console.log('No more pages on stack, quitting...');
navigator.app.exitApp();
}
}, false);
});
I have <ons-navigator id="navigator" var="appnavigator">
in the body.
This pops a page, and then quits the application. Why is that? I'm using Onsen UI v 1.3.14 and Cordova 5.3.3.