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

    [Solved] Intercept/Listen on Back Button Click of Browser/Phone

    Help
    2
    5
    858
    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.
    • S
      snowdrop last edited by Shone

      Good day. Is there any way to intercept/listen on the back button of the browser/phone? I would like to determine the route the user will be directed when the back button is clicked/pressed. For example in my situation, when the user clicks the back button simultaneously for a couple of times, the user is directed to the login page which is the app’s previous window(s). I would like to retain the functionality that the user can go back to the previous page but prevent it from visiting the login page when the user is already logged in.

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

        did you check the docs? https://quasar-framework.org/components/handling-back-button.html.
        what i can think is to use router guard and vuex store for maintaining the back button clicks.

        S 1 Reply Last reply Reply Quote 0
        • S
          snowdrop @metalsadman last edited by

          @metalsadman Yup I did. But it doesn’t fit with my use case since it can’t determine what is the next route when the user clicked the back button. Router guards only handle the beforeEach and afterEach, but it can’t handle when the user clicked the back button based on my tests.

          1 Reply Last reply Reply Quote 0
          • S
            snowdrop last edited by

            It seems that I am implementing the router guards the wrong way. After correcting the code, the router guards now detects changes in URL even if the uses the back button.

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

              i put a Router.beforeEach in the router/index.js, to perform checks/validations etc…

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