[SOLVED] How to emit q-select @input only on change
-
Currently, if you use select
@input
it receives a value even if I click on the same option in the select which is currently selected. How I find with@input
event that the select has changed it’s value? -
I’m not sure if it’s doable but you can put a watch on your model.
In the watch, you’ll have the new value and the old value.watch: { myModel (newValue, oldValue) { if (newValue != oldValue) { // value changed. } } }
-
-
@jraez
Thanks for the one of the solutions, but it doesn’t work in my case.
While I’m going to usewatch
value will be already changed. And because I’m passing this value into a parent component via@emit
that not what I want. Would be great to have more clear solution. -
@Shoooryuken
There are no such event@change
forq-select
anymore since around v1.0. I’ve looked into theq-select
sourcecode, but haven’t found any possible solution to do that easily. Might be I’ve looked in the wrong direction. -
You can save the initial value in
data
when your child component ismounted
. Then in@input
check if the value is different than initial. -
@dmitry-polushkin use lazy input, ie’
:value="model"... @input="doSomething"
. -
@metalsadman thanks, that solved my issue. Really forgot the idea behind the v-model.