No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Is there a way to override the Android back button behaviour?

    Framework
    3
    5
    795
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      walfin last edited by

      I do not want it to go to the last visited route. I have gone to https://quasar.dev/vue-directives/go-back and there doesn’t seem to be any indication on how I can add an event handler to override the default back button behaviour.

      1 Reply Last reply Reply Quote 0
      • qyloxe
        qyloxe last edited by qyloxe

        well, I won’t help you with global android hook for system behaviour, BUT if you just want to protect your submitted forms or it is a similar problem, than you may be interested in router.replace functionality instead of router.push or router.go. This “replace” function allows you to directly manipulate browser history and protects your input forms:

        https://router.vuejs.org/guide/essentials/navigation.html#history-manipulation

        Of course, there may be situations, where for total form protection (for example transactional db store) you may need also this:

        https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards

        1 Reply Last reply Reply Quote 0
        • W
          walfin last edited by walfin

          I’m already using $router.replace for everything. Currently, what happens is that when it is on another route, pressing the back button leads back to the home screen (which I do not want, I’d rather just send the app to the background).

          Previously when I used OnsenUI before I discovered Quasar, I could write a function to manually override the Android back button event handler. I’m surprised quasar doesn’t seem to have this feature.

          Or at least maybe a warning dialog could be displayed when the backbutton is pressed if the user has a partially filled form that hasn’t been saved.

          1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman last edited by

            quasar is using vue router you have to understand how to do that, and well you can add a listener for back button document.addEventListener('backbutton', handler), and if you are using cordova there are several plugins for that as well.

            1 Reply Last reply Reply Quote 0
            • W
              walfin last edited by

              Got it on how I can add my own back button listener. How do I disable the default back button behaviour in quasar? I don’t have the listener function so I can’t call document.removeEventListener.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post