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

    Tabs event before leave the tab

    Framework
    2
    5
    716
    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.
    • volkano
      volkano last edited by

      I want to know when a user clicks another tab and before the new tab is loaded.

      I have 3 tabs, one of them has form components. If a user changes some of the form elements and clicks another tab, I want to know and ask her/him if they want to save the new data before Quasar loads the new tab. I can’t find any event for that in the tabs components. Is it possible?

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

        I am using q-route-tab and I use a store with attribute called currentPage. From my content pages, I set currentPage to the name of the new page (as selected by the tab) in the created function. Any watcher ( watch: ) will get notified of the change.
        Is that what you are trying to achieve?

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

          I use a similar solution but that moment it’s too late because the new tab has already loaded by Quasar. I need to be triggered before loading to the new tab.

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

            You can alway use the global message event system: this.$root.$emit

            beforeDestroy: function () {
              this.$root.$emit('tab:closing', this.myTabName)
            }
            
            beforeMount: function () {
              this.$root.$on('tab:closing', this.onTabClosing)
            },
            beforeDestroy: function () {
              // alway turn off global event listener
              this.$root.$off('tab:closing', this.onTabClosing)
            },
            methods: {
              onTabClosing: function (tabName) {
                // do something
              }
            }
            

            Hope that might help…

            1 Reply Last reply Reply Quote 1
            • volkano
              volkano last edited by

              Thank you @Hawkeye64 I think It’ll help me, I’ll investigate it.

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