Skip to content

Commit 20bbd59

Browse files
committed
Add validateDebounceTime formOption to fix #309
1 parent dfe823c commit 20bbd59

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/fields/abstractField.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { get as objGet, each, isFunction, isString, isArray } from "lodash";
1+
import { get as objGet, each, isFunction, isString, isArray, debounce } from "lodash";
22
import validators from "../utils/validators";
33
import { slugifyFormID } from "../utils/schema";
44

@@ -64,8 +64,15 @@ export default {
6464
this.schema.onChanged.call(this, this.model, newValue, oldValue, this.schema);
6565
}
6666

67-
if (this.$parent.options && this.$parent.options.validateAfterChanged === true){
68-
this.validate();
67+
if (this.$parent.options && this.$parent.options.validateAfterChanged === true) {
68+
if (this.$parent.options.validateDebounceTime > 0) {
69+
if (!this.debouncedValidate)
70+
this.debouncedValidate = debounce(this.validate.bind(this), this.$parent.options.validateDebounceTime);
71+
72+
this.debouncedValidate();
73+
} else {
74+
this.validate();
75+
}
6976
}
7077
}
7178
}

0 commit comments

Comments
 (0)