|
@@ -11859,9 +11859,19 @@ define('select2/data/select',[
|
|
};
|
|
};
|
|
|
|
|
|
SelectAdapter.prototype.option = function (data) {
|
|
SelectAdapter.prototype.option = function (data) {
|
|
- var option = document.createElement('option');
|
|
|
|
|
|
+ var option;
|
|
|
|
|
|
- option.value = data.id;
|
|
|
|
|
|
+ if (data.children) {
|
|
|
|
+ option = document.createElement('optgroup');
|
|
|
|
+ option.label = data.text;
|
|
|
|
+ } else {
|
|
|
|
+ option = document.createElement('option');
|
|
|
|
+ option.innerText = data.text;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (data.id) {
|
|
|
|
+ option.value = data.id;
|
|
|
|
+ }
|
|
|
|
|
|
if (data.disabled) {
|
|
if (data.disabled) {
|
|
option.disabled = true;
|
|
option.disabled = true;
|
|
@@ -11871,8 +11881,6 @@ define('select2/data/select',[
|
|
option.selected = true;
|
|
option.selected = true;
|
|
}
|
|
}
|
|
|
|
|
|
- option.innerText = data.text;
|
|
|
|
-
|
|
|
|
var $option = $(option);
|
|
var $option = $(option);
|
|
|
|
|
|
var normalizedData = this._normalizeItem(data);
|
|
var normalizedData = this._normalizeItem(data);
|
|
@@ -11902,7 +11910,7 @@ define('select2/data/select',[
|
|
};
|
|
};
|
|
} else if ($option.is('optgroup')) {
|
|
} else if ($option.is('optgroup')) {
|
|
data = {
|
|
data = {
|
|
- text: $option.attr('label'),
|
|
|
|
|
|
+ text: $option.prop('label'),
|
|
children: []
|
|
children: []
|
|
};
|
|
};
|
|
|
|
|
|
@@ -11979,7 +11987,7 @@ define('select2/data/array',[
|
|
|
|
|
|
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
|
ArrayAdapter.__super__.constructor.call(this, $element, options);
|
|
|
|
|
|
- this.convertToOptions(data);
|
|
|
|
|
|
+ $element.append(this.convertToOptions(data));
|
|
}
|
|
}
|
|
|
|
|
|
Utils.Extend(ArrayAdapter, SelectAdapter);
|
|
Utils.Extend(ArrayAdapter, SelectAdapter);
|
|
@@ -12004,6 +12012,8 @@ define('select2/data/array',[
|
|
return self.item($(this)).id;
|
|
return self.item($(this)).id;
|
|
}).get();
|
|
}).get();
|
|
|
|
|
|
|
|
+ var $options = [];
|
|
|
|
+
|
|
// Filter out all items except for the one passed in the argument
|
|
// Filter out all items except for the one passed in the argument
|
|
function onlyItem (item) {
|
|
function onlyItem (item) {
|
|
return function () {
|
|
return function () {
|
|
@@ -12012,8 +12022,7 @@ define('select2/data/array',[
|
|
}
|
|
}
|
|
|
|
|
|
for (var d = 0; d < data.length; d++) {
|
|
for (var d = 0; d < data.length; d++) {
|
|
- var item = data[d];
|
|
|
|
- item.id = item.id.toString();
|
|
|
|
|
|
+ var item = this._normalizeItem(data[d]);
|
|
|
|
|
|
// Skip items which were pre-loaded, only merge the data
|
|
// Skip items which were pre-loaded, only merge the data
|
|
if (existingIds.indexOf(item.id) >= 0) {
|
|
if (existingIds.indexOf(item.id) >= 0) {
|
|
@@ -12031,8 +12040,16 @@ define('select2/data/array',[
|
|
|
|
|
|
var $option = this.option(item);
|
|
var $option = this.option(item);
|
|
|
|
|
|
- this.$element.append($option);
|
|
|
|
|
|
+ if (item.children) {
|
|
|
|
+ var $children = this.convertToOptions(item.children);
|
|
|
|
+
|
|
|
|
+ $option.append($children);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $options.push($option);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return $options;
|
|
};
|
|
};
|
|
|
|
|
|
return ArrayAdapter;
|
|
return ArrayAdapter;
|