only call initSelection() when there is actual input. avoids making users implement empty input check in their initSelection()s
This commit is contained in:
parent
19810405ce
commit
a16190c822
10
select2.js
10
select2.js
@ -444,7 +444,6 @@
|
|||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -838,11 +837,13 @@
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if ($.isFunction(this.opts.initSelection)) {
|
if ($.isFunction(this.opts.initSelection)) {
|
||||||
|
if (this.select || this.opts.element.val() !== "") {
|
||||||
selected = this.opts.initSelection.call(null, this.opts.element);
|
selected = this.opts.initSelection.call(null, this.opts.element);
|
||||||
if (selected !== undefined && selected != null) {
|
if (selected !== undefined && selected != null) {
|
||||||
this.updateSelection(selected);
|
this.updateSelection(selected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.setPlaceholder();
|
this.setPlaceholder();
|
||||||
};
|
};
|
||||||
@ -1074,11 +1075,13 @@
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if ($.isFunction(this.opts.initSelection)) {
|
if ($.isFunction(this.opts.initSelection)) {
|
||||||
|
if (this.select || this.opts.element.val() !== "") {
|
||||||
data = this.opts.initSelection.call(null, this.opts.element);
|
data = this.opts.initSelection.call(null, this.opts.element);
|
||||||
if (data !== undefined && data != null) {
|
if (data !== undefined && data != null) {
|
||||||
this.updateSelection(data);
|
this.updateSelection(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set the placeholder if necessary
|
// set the placeholder if necessary
|
||||||
this.clearSearch();
|
this.clearSearch();
|
||||||
@ -1338,4 +1341,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}(jQuery));
|
}
|
||||||
|
(jQuery)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user