Revert "changes on updateResults, populate by @cervengoc on #781"
This reverts commit 12e0de21ae4d753eee3950be9b95848a82df6f15.
This commit is contained in:
parent
12e0de21ae
commit
c14f45cb6c
52
select2.js
52
select2.js
@ -919,46 +919,39 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
populate=function(results, container, depth) {
|
populate=function(results, container, depth) {
|
||||||
|
|
||||||
var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted, formattedClass;
|
var i, l, result, selectable, disabled, compound, node, label, innerContainer, formatted;
|
||||||
|
|
||||||
results = opts.sortResults(results, container, query);
|
results = opts.sortResults(results, container, query);
|
||||||
|
|
||||||
// collect the created nodes for bulk append
|
|
||||||
var nodes = [];
|
|
||||||
for (i = 0, l = results.length; i < l; i = i + 1) {
|
for (i = 0, l = results.length; i < l; i = i + 1) {
|
||||||
|
|
||||||
result=results[i];
|
result=results[i];
|
||||||
|
|
||||||
disabled = (result.disabled === true);
|
disabled = (result.disabled === true);
|
||||||
selectable = (!disabled) && (id(result) !== undefined);
|
selectable = (!disabled) && (id(result) !== undefined);
|
||||||
|
|
||||||
compound=result.children && result.children.length > 0;
|
compound=result.children && result.children.length > 0;
|
||||||
|
|
||||||
node ="<li class=\"";
|
node=$("<li></li>");
|
||||||
node += "select2-results-dept-" + depth;
|
node.addClass("select2-results-dept-"+depth);
|
||||||
node += " select2-result";
|
node.addClass("select2-result");
|
||||||
node+= selectable ? " select2-result-selectable" : " select2-result-unselectable";
|
node.addClass(selectable ? "select2-result-selectable" : "select2-result-unselectable");
|
||||||
if (disabled)
|
if (disabled) { node.addClass("select2-disabled"); }
|
||||||
node += " select2-disabled";
|
if (compound) { node.addClass("select2-result-with-children"); }
|
||||||
if (compound)
|
node.addClass(self.opts.formatResultCssClass(result));
|
||||||
node += " select2-result-with-children";
|
node.attr("role", "presentation");
|
||||||
formattedClass = self.opts.formatResultCssClass(result);
|
|
||||||
if (formattedClass != undefined)
|
|
||||||
node += " " + formattedClass;
|
|
||||||
node += "\" role=\"presentation\">";
|
|
||||||
|
|
||||||
label = "<div class=\"select2-result-label\"";
|
label=$(document.createElement("div"));
|
||||||
label += " id=\"select2-result-label-" + nextUid() + "\"";
|
label.addClass("select2-result-label");
|
||||||
label += " role=\"option\"";
|
label.attr("id", "select2-result-label-" + nextUid());
|
||||||
label += ">";
|
label.attr("role", "option");
|
||||||
formatted = opts.formatResult(result, label, query, self.opts.escapeMarkup);
|
|
||||||
if (formatted !== undefined)
|
|
||||||
label += formatted;
|
|
||||||
label += "</div>";
|
|
||||||
|
|
||||||
node += label;
|
formatted=opts.formatResult(result, label, query, self.opts.escapeMarkup);
|
||||||
node += "</li>";
|
if (formatted!==undefined) {
|
||||||
|
label.html(formatted);
|
||||||
|
node.append(label);
|
||||||
|
}
|
||||||
|
|
||||||
// I still used jQuery wrapping for setting "data" below
|
|
||||||
node = $(node);
|
|
||||||
|
|
||||||
if (compound) {
|
if (compound) {
|
||||||
|
|
||||||
@ -969,10 +962,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
}
|
}
|
||||||
|
|
||||||
node.data("select2-data", result);
|
node.data("select2-data", result);
|
||||||
nodes.push(node[0]);
|
container.append(node);
|
||||||
}
|
}
|
||||||
// bulk append the created nodes
|
|
||||||
container.append(nodes);
|
|
||||||
liveRegion.text(opts.formatMatches(results.length));
|
liveRegion.text(opts.formatMatches(results.length));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user