Skip to content

Commit ee684f0

Browse files
committed
fixes #345 - declare debouncedValidateFunc and set it when debouncedValidate() is called... vue 2.2.0 prevents you from attaching methods/properties to components that have not been declared
1 parent 776aff1 commit ee684f0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/fields/abstractField.js

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

@@ -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();
@@ -81,6 +79,7 @@ export default {
8179

8280
methods: {
8381
validate(calledParent) {
82+
console.log('validating', performance.now());
8483
this.clearValidationErrors();
8584

8685
if (this.schema.validator && this.schema.readonly !== true && this.disabled !== true) {
@@ -130,7 +129,14 @@ export default {
130129

131130
return this.errors;
132131
},
133-
132+
debouncedValidate() {
133+
if(!isFunction(this.debouncedValidateFunc)) {
134+
console.log('debouncedValidate', 'config', objGet(this, '$parent.optionsvalidateDebounceTime', 500));
135+
this.debouncedValidateFunc = debounce(this.validate.bind(this), objGet(this, '$parent.options.validateDebounceTime', 500));
136+
}
137+
console.log('debouncedValidate', performance.now());
138+
this.debouncedValidateFunc();
139+
},
134140
clearValidationErrors() {
135141
this.errors.splice(0);
136142
},

0 commit comments

Comments
 (0)