Skip to content

Commit

Permalink
fix data helper when used with compound choices without a text attrib…
Browse files Browse the repository at this point in the history
…ute. fixes #370
  • Loading branch information
ivaynberg committed Aug 31, 2012
1 parent 7baa3b9 commit 222fa7e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 222fa7e

Please sign in to comment.