How to wait for q-input change event execution
-
I want to wait for q-input change event execution when a button is clicked, but this.$nextTick doesn’t seem to do it. I could do setTimeout with a large number of milliseconds, but it is not a good way.
Test Case:
https://jsfiddle.net/apptaro/fv269qn0/13/
Enter some text after “abc”, and click “Submit” button directly without losing focus from the input field. Inside onClick, I want to wait for onChange execution using this.$nextTick, but I can’t. -
Can you not use v-model ?
The problem is that
text
will not change until you the focus leaves the input which seems after the@click
.
https://jsfiddle.net/gezaatturigezacom/fzsantm5/ -
Can you not use v-model ?
No, in my case, I need to check and replace the value when needed on blur, so I need to use :value and @change. I can’t use v-model or @input.I found it works correctly if I use a simple text input and a simple button:
https://jsfiddle.net/apptaro/fv269qn0/22/I also found it works correctly if I use Quasar v1.0.0-beta.18:
https://jsfiddle.net/apptaro/fv269qn0/29/Finally, I solved the issue by using @change.native:
https://jsfiddle.net/apptaro/fv269qn0/32/Thank you!
-
Actually, I found that I have to wait 200ms:
https://github.com/quasarframework/quasar/blob/v0.17/src/mixins/input.js#L41
https://jsfiddle.net/apptaro/fv269qn0/36/So, here’s the note:
@change and @blur of q-input in quasar 0.17 are delayed 200ms!