How to set q-btn-toggle into initial state?
-
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? -
Can you try again to explain what it is you are attempting to accomplish? It isn’t quite making sense to me.
Scott
-
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.
-
Ah. Ok. Like this? https://codepen.io/smolinari/pen/XLGMWX
Scott
-
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. -
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
-
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.
-
Out of the box none, a workaround is doable ie. Storing previous value and comparing it to current model on click.
-
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
-
@s-molinari i think he wanted ability to deselect(model=null) the selected button, but yeah it’s not a normal behavior.
-
This post is deleted! -
@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. -
-
@metalsadman Yes mousedown solves it. Thank you that is exactly what I was looking for.