I am using the Quasar CLI version 0.15.20 which has the dialog $q.dialog for confirmation. I want to control the backbutton on android device not to go back to previous page if the user doesnt confirm to leave. I used this below function but it doesnt work. It keeps going back before the dialog pop up asking to leave the page. any idea how to prevent it?
backButton (e){
e.preventDefault()
if (this.$route.name === 'session-show') {
this.$q.dialog({
title: 'Warning',
message: 'Are you sure you want to leave without save?',
ok: 'Yes',
cancel: 'Cancel'
}).then(() => {
this.$router.go(-1)
this.$q.notify('Data is removed!')
}).catch(() => {
console.log('stay in current page')
})
}
}
and I used this to call the event
document.addEventListener('backbutton', this.backButton, false)