Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Commit ac3f95b

Browse files
committed
Trying to fix issue ,#1
1 parent 25532ed commit ac3f95b

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/component.vue

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<input type="text" @blur="onBlur">
2+
<input type="text" @blur="onBlur" @input="onInput">
33
</template>
44

55
<script>
@@ -31,31 +31,25 @@
3131
},
3232
},
3333
data() {
34-
return {
35-
onChangeFn: null
36-
}
34+
return {}
3735
},
3836
mounted() {
39-
// Backup onChange callback
40-
this.onChangeFn = this.options.onChange;
41-
// Inject our onChange callback
42-
let newOptions = jQuery.extend(true, {}, this.options, {onChange: this.onChange});
37+
// Clone configs
38+
let newOptions = jQuery.extend(true, {}, this.options);
4339
// Lastly init the mask
4440
jQuery(this.$el).mask(this.mask, newOptions);
4541
// Set initial value
4642
jQuery(this.$el).val(jQuery(this.$el).masked(this.value));
4743
},
4844
methods: {
4945
/**
50-
* Update v-model upon change triggered by plugin itself
46+
* Update v-model upon change triggered by user
5147
*/
52-
onChange(...args) {
53-
let toEmit = this.raw ? jQuery(this.$el).cleanVal() : arguments[0];
54-
this.$emit('input', toEmit);
55-
56-
if (typeof this.onChangeFn === 'function') {
57-
this.onChangeFn.call(this, ...args)
58-
}
48+
onInput(event) {
49+
this.$nextTick(() => {
50+
let toEmit = this.raw ? jQuery(this.$el).cleanVal() : event.target.value;
51+
this.$emit('input', toEmit);
52+
});
5953
},
6054
onBlur(event) {
6155
this.$emit('blur', this.value)
@@ -72,7 +66,6 @@
7266
},
7367
beforeDestroy() {
7468
jQuery(this.$el).unmask();
75-
this.onChangeFn = null
7669
}
7770
}
7871
</script>

0 commit comments

Comments
 (0)