Vue: v-on="change" not triggered with filters

Created on 21 Jun 2015  路  1Comment  路  Source: vuejs/vue

Hey,

I'm working with form fields, I want to fire a method when the input is changed, this is working as expected on fields without a filter, but when the input is changed by a filter, the change event isnt working (while searching for other events that might work, have also tried input and broadcast to no avail).
Below are 2 example form inputs:

<input type="text"
    name="items[@{{ $index }}][rate]" 
    v-model="rate | decimalPlaces 2" 
    number 
    debounce="500"
    v-on="change: listItemsChanged">

<input type="text"
    name="items[@{{ $index }}][quantity]" 
    v-model="quantity" 
    number 
    v-on="change: listItemsChanged">

The first doesnt work when the filter changes the input and I exit the field, but it does work if I exit the field before the debounce kicks in (so as expected.
The second field works fine.

Not sure if this is expected behaviour or not, if it is, why? And what's the recommended workaround?

Thanks!

Most helpful comment

The change listener simply listens to the native change event, which does not fire until you blur the input.

v-on="input: onChange" should work as you type, if not you need to provide a jsfiddle reproduction.

Finally, if you want to react to the data changes, don't rely on DOM listeners, the better way to do it is just use $watch() on the underlying data directly.

>All comments

The change listener simply listens to the native change event, which does not fire until you blur the input.

v-on="input: onChange" should work as you type, if not you need to provide a jsfiddle reproduction.

Finally, if you want to react to the data changes, don't rely on DOM listeners, the better way to do it is just use $watch() on the underlying data directly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

6pm picture 6pm  路  3Comments

loki0609 picture loki0609  路  3Comments

hiendv picture hiendv  路  3Comments

paulpflug picture paulpflug  路  3Comments

franciscolourenco picture franciscolourenco  路  3Comments