0

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)
  • Your function is it linked to `backbutton` event ? – Djiggy Aug 20 '18 at 10:43
  • yes it is. I used this document.addEventListener('backbutton', this.backButton, false) in created() in Quasar. It worked if i set it to exit the app on homepage. – chocolate sar Aug 20 '18 at 10:46

0 Answers0