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

    How to set q-btn-toggle into initial state?

    Framework
    3
    14
    1543
    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.
    • C
      Cobeland last edited by Cobeland

      How it is possible to reset q-btn-toggle with a selected value in its initial state (value=null)?
      Ideally this would be done by select the selected value again. Any ideas?

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Can you try again to explain what it is you are attempting to accomplish? It isn’t quite making sense to me.

        Scott

        1 Reply Last reply Reply Quote 0
        • C
          Cobeland last edited by Cobeland

          Lets assume we have a group of three toggle buttons. One of the toggle button is selected. Now I want to unselect the togglebutton so that the value is null again as it was initially.

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            Ah. Ok. Like this? https://codepen.io/smolinari/pen/XLGMWX

            Scott

            1 Reply Last reply Reply Quote 0
            • C
              Cobeland last edited by

              Yes thanks. But I would like to reset the value to null
              reset () {
              this.model = ‘null’
              }
              but without an extra button. Only by clicking on a selected button. Ideally this would be a build in feature of q-btn-toggle.

              1 Reply Last reply Reply Quote 0
              • s.molinari
                s.molinari last edited by

                So, making a selection, yet not showing a selected button? Um, that isn’t a toggle. 😄

                Maybe you want QBtnGroup? https://quasar.dev/vue-components/button-group

                Scott

                1 Reply Last reply Reply Quote 0
                • C
                  Cobeland last edited by Cobeland

                  I am using q-btn-toggle (https://quasar.dev/vue-components/button-toggle#QBtnToggle-API) and if I select a toggle button I would like also to unselect this button. So that the value is null again. Unfortunately we can only select and not unselect a toggle button.

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

                    Out of the box none, a workaround is doable ie. Storing previous value and comparing it to current model on click.

                    1 Reply Last reply Reply Quote 0
                    • s.molinari
                      s.molinari last edited by s.molinari

                      I’m still not certain what the use case is. But, how about this? I’m not comparing anything. Just storing the value in a different property.

                      https://codepen.io/smolinari/pen/XLGMWX

                      Scott

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

                        @s-molinari i think he wanted ability to deselect(model=null) the selected button, but yeah it’s not a normal behavior.

                        C 1 Reply Last reply Reply Quote 0
                        • C
                          Cobeland @metalsadman last edited by

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • C
                            Cobeland last edited by

                            @metalsadman @s-molinari Exactly. I had this once with JQuery mobile out of the box. The problem is I have to check if the state is null. But if I click/select the value is already set.
                            So “comparing it to current model on click” is unfortunately not possible cause the new value is already set by click. Need something before_click.

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

                              @Cobeland https://codepen.io/metalsadman/pen/agMapB?editors=1011

                              1 Reply Last reply Reply Quote 1
                              • C
                                Cobeland last edited by Cobeland

                                @metalsadman Yes mousedown solves it. Thank you that is exactly what I was looking for.

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