1
0
mirror of synced 2024-11-22 21:16:10 +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);
} else {
// val is an object. !val is true for [undefined,null,'']
if (this.opts.initSelection) {
if (this.opts.initSelection && val) {
that = this;
this.opts.initSelection(this.opts.element.val(val), function(data){
self.opts.element.val(!data ? "" : self.id(data));
@ -1915,7 +1915,7 @@
});
this.updateSelection(data);
} else {
if (this.opts.initSelection) {
if (this.opts.initSelection && val !== null) {
this.opts.initSelection(this.opts.element.val(val), function(newVal){
$(newVal).each(function () { data.push(self.id(this)); });
self.setVal(data);