I currently have a multi page (Android) application that allows you to go back a page with the hardware back button. I would like to do 1 of 2 things:
Disable the back button when a ‘sheet-modal’ is displayed, re-enable it when ‘sheet-modal’ is closed.
or
If a ‘sheet-modal’ is displayed, instead of the hardware back button going back to the current page (which still leaves the sheet modal displayed), have it only close the sheet modal and not navigate back a page unless the user hits back again after sheet modals is closed.
Turns out I was overlooking a key point. I had removed including Cordova.js in my build so the document.addEventListener would never trigger. Your code works perfectly and I ended up doing exactly what I wanted with the following code:
$$('#error-modal').on('sheet:open', function () {
document.addEventListener("backbutton", chkModal, false);
});
function chkModal (e) {
if (app.sheet.get('.sheet-modal') && app.sheet.get('.sheet-modal').opened) { // Sheet modal is open
app.sheet.close();
document.removeEventListener("backbutton", chkModal, false);
}
}