Skip to content

Commit 5c42f3e

Browse files
authored
Merge pull request #356 from zoul0813/feature/345-debounced-validate-fix
fixes #345 - declare debouncedValidateFunc
2 parents 776aff1 + 025b541 commit 5c42f3e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/fields/abstractField.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export default {
2424

2525
data() {
2626
return {
27-
errors: []
27+
errors: [],
28+
debouncedValidateFunc: null
2829
};
2930
},
3031

@@ -66,9 +67,6 @@ export default {
6667

6768
if (this.$parent.options && this.$parent.options.validateAfterChanged === true) {
6869
if (this.$parent.options.validateDebounceTime > 0) {
69-
if (!this.debouncedValidate)
70-
this.debouncedValidate = debounce(this.validate.bind(this), this.$parent.options.validateDebounceTime);
71-
7270
this.debouncedValidate();
7371
} else {
7472
this.validate();
@@ -130,7 +128,12 @@ export default {
130128

131129
return this.errors;
132130
},
133-
131+
debouncedValidate() {
132+
if(!isFunction(this.debouncedValidateFunc)) {
133+
this.debouncedValidateFunc = debounce(this.validate.bind(this), objGet(this, "$parent.options.validateDebounceTime", 500));
134+
}
135+
this.debouncedValidateFunc();
136+
},
134137
clearValidationErrors() {
135138
this.errors.splice(0);
136139
},

0 commit comments

Comments
 (0)