1
0
mirror of synced 2024-11-26 14:56:07 +03:00

Added truth checks to avoid unnecessarily firing initSelection.

Signed-off-by: Igor Vaynberg <igor.vaynberg@gmail.com>
This commit is contained in:
Dean Sofer 2012-07-20 19:15:46 -07:00 committed by Igor Vaynberg
parent d54fd4dd0e
commit ad8fd257aa

View File

@ -1448,7 +1448,7 @@
this.updateSelection(data); this.updateSelection(data);
} else { } else {
// val is an object. !val is true for [undefined,null,''] // val is an object. !val is true for [undefined,null,'']
if (this.opts.initSelection) { if (this.opts.initSelection && val) {
that = this; that = this;
this.opts.initSelection(this.opts.element.val(val), function(data){ this.opts.initSelection(this.opts.element.val(val), function(data){
self.opts.element.val(!data ? "" : self.id(data)); self.opts.element.val(!data ? "" : self.id(data));
@ -1915,7 +1915,7 @@
}); });
this.updateSelection(data); this.updateSelection(data);
} else { } else {
if (this.opts.initSelection) { if (this.opts.initSelection && val !== null) {
this.opts.initSelection(this.opts.element.val(val), function(newVal){ this.opts.initSelection(this.opts.element.val(val), function(newVal){
$(newVal).each(function () { data.push(self.id(this)); }); $(newVal).each(function () { data.push(self.id(this)); });
self.setVal(data); self.setVal(data);