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 activate a method only when the q-tab is selected?

    Help
    2
    4
    508
    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
      WherelessUpdate last edited by

      I wanted to avoid using q-route-tab (having a new route), however I need to activate a certain method (that would fetch data from my server) only when the tab is selected. Right now, I see that it activates the method whenever the page is loaded. Is there a way to avoid that? Perhaps an “is-selected” as a prop on q-tab-pane?

      Thank you.

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

        Use q-tab and use the @select event to handle your fetch.

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

          I ended up adding a @select="selected = true" to the q-tab and :selected="selected"to the component containing the q-tab-pane, which watches this prop. If the prop selected equals true, then it fetches the data from server.

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

            Why not @select="fetchDataFromServer"???

            fetchDataFromServer: function () {
                // fetch data from the server
            }
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post