Closed gaop closed 6 years ago
I have found out. The error will be triggered when setting "option.matcher" to do custom filter like this:
options: Select2Options = <Select2Options> {
...,
matcher: (term: string, text: string, option: any) => {
// do customer filter
}
};
Finally, I have fix the bug using async & await (ES6):
private async initPlugin() {
...
if(options.matcher) {
let oldMatcher: any = await this.requireOldMatcher();
options.matcher = oldMatcher(options.matcher);
this.element.select2(options);
if (typeof this.value !== 'undefined') {
this.setElementValue(this.value);
}
}
...
}
async requireOldMatcher() : Promise<any> {
return new Promise<any[]>(resolve => {
jQuery.fn.select2.amd.require(['select2/compat/matcher'], (oldMatcher: any) => {
resolve(oldMatcher);
});
});
}
I'm using the matcher option and seeing the same error message.
fixed with #115 in version 1.0.0-beta.13
someone else has the same problem? [version: 1.0.0-beta.11]