1
0
mirror of synced 2024-11-26 06:46:04 +03:00

only validate initSelection is present on val() if we are not clearing

This commit is contained in:
Igor Vaynberg 2013-05-31 15:29:14 -07:00
parent 9a3666edb5
commit cb7b5464a1

View File

@ -2182,14 +2182,14 @@ the specific language governing permissions and limitations under the Apache Lic
this.triggerChange({added: data, removed:oldData});
}
} else {
if (this.opts.initSelection === undefined) {
throw new Error("cannot call val() if initSelection() is not defined");
}
// val is an id. !val is true for [undefined,null,'',0] - 0 is legal
if (!val && val !== 0) {
this.clear(triggerChange);
return;
}
if (this.opts.initSelection === undefined) {
throw new Error("cannot call val() if initSelection() is not defined");
}
this.opts.element.val(val);
this.opts.initSelection(this.opts.element, function(data){
self.opts.element.val(!data ? "" : self.id(data));