1
0
mirror of synced 2024-11-22 13:06:08 +03:00

only call initSelection() when there is actual input. avoids making users implement empty input check in their initSelection()s

This commit is contained in:
Igor Vaynberg 2012-04-10 07:45:09 -07:00
parent 19810405ce
commit a16190c822

View File

@ -444,7 +444,6 @@
}); });
return data; return data;
} }
} }
} }
} }
@ -838,9 +837,11 @@
})); }));
if ($.isFunction(this.opts.initSelection)) { if ($.isFunction(this.opts.initSelection)) {
selected = this.opts.initSelection.call(null, this.opts.element); if (this.select || this.opts.element.val() !== "") {
if (selected !== undefined && selected != null) { selected = this.opts.initSelection.call(null, this.opts.element);
this.updateSelection(selected); if (selected !== undefined && selected != null) {
this.updateSelection(selected);
}
} }
} }
@ -1074,9 +1075,11 @@
})); }));
if ($.isFunction(this.opts.initSelection)) { if ($.isFunction(this.opts.initSelection)) {
data = this.opts.initSelection.call(null, this.opts.element); if (this.select || this.opts.element.val() !== "") {
if (data !== undefined && data != null) { data = this.opts.initSelection.call(null, this.opts.element);
this.updateSelection(data); if (data !== undefined && data != null) {
this.updateSelection(data);
}
} }
} }
@ -1324,7 +1327,7 @@
return (value === undefined) ? this : value; return (value === undefined) ? this : value;
}; };
// exports // exports
window.Select2 = { window.Select2 = {
query: { query: {
ajax: ajax, ajax: ajax,
@ -1338,4 +1341,7 @@
} }
}; };
}(jQuery)); }
(jQuery)
)
;