diff --git a/select2.js b/select2.js index de25c8b2..580d32ed 100644 --- a/select2.js +++ b/select2.js @@ -919,46 +919,39 @@ the specific language governing permissions and limitations under the Apache Lic 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); - // collect the created nodes for bulk append - var nodes = []; for (i = 0, l = results.length; i < l; i = i + 1) { result=results[i]; + disabled = (result.disabled === true); selectable = (!disabled) && (id(result) !== undefined); + compound=result.children && result.children.length > 0; - node ="
  • "; + node=$("
  • "); + node.addClass("select2-results-dept-"+depth); + node.addClass("select2-result"); + node.addClass(selectable ? "select2-result-selectable" : "select2-result-unselectable"); + if (disabled) { node.addClass("select2-disabled"); } + if (compound) { node.addClass("select2-result-with-children"); } + node.addClass(self.opts.formatResultCssClass(result)); + node.attr("role", "presentation"); - label = "