We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 09f24fd commit b7c952aCopy full SHA for b7c952a
1 file changed
select2.js
@@ -579,7 +579,7 @@
579
opts.query = this.bind(function (query) {
580
var data = { results: [], more: false },
581
term = query.term,
582
- process;
+ children, firstChild, process;
583
584
process=function(element, collection) {
585
var group;
@@ -596,7 +596,17 @@
596
}
597
};
598
599
- element.children().each2(function(i, elm) { process(elm, data.results); });
+ children=element.children();
600
+
601
+ // ignore the placeholder option if there is one
602
+ if (this.getPlaceholder() !== undefined && children.length > 0) {
603
+ firstChild = children[0];
604
+ if ($(firstChild).text() === "") {
605
+ children=children.not(firstChild);
606
+ }
607
608
609
+ children.each2(function(i, elm) { process(elm, data.results); });
610
611
query.callback(data);
612
});
0 commit comments