Przeglądaj źródła

fix data helper when used with compound choices without a text attribute. fixes #370

Igor Vaynberg 13 lat temu
rodzic
commit
222fa7e415
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      select2.js

+ 6 - 2
select2.js

@@ -358,10 +358,14 @@
             }
 
             process = function(datum, collection) {
-                var group;
+                var group, attr;
                 datum = datum[0];
                 if (datum.children) {
-                    group = { text: text(datum), children: [] };
+                    group = {};
+                    for (attr in datum) {
+                        if (datum.hasOwnProperty(attr)) group[attr]=datum[attr];
+                    }
+                    group.children=[];
                     $(datum.children).each2(function(i, childDatum) { process(childDatum, group.children); });
                     if (group.children.length) {
                         collection.push(group);