|
@@ -714,6 +714,23 @@ S2.define('select2/utils',[
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ // Append an array of jQuery nodes to a given element.
|
|
|
|
+ Utils.appendMany = function ($element, $nodes) {
|
|
|
|
+ // jQuery 1.7.x does not support $.fn.append() with an array
|
|
|
|
+ // Fall back to a jQuery object collection using $.fn.add()
|
|
|
|
+ if ($.fn.jquery.substr(0, 3) === '1.7') {
|
|
|
|
+ var $jqNodes = $();
|
|
|
|
+
|
|
|
|
+ $.map($nodes, function (node) {
|
|
|
|
+ $jqNodes = $jqNodes.add(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ $nodes = $jqNodes;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $element.append($nodes);
|
|
|
|
+ };
|
|
|
|
+
|
|
return Utils;
|
|
return Utils;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -1565,7 +1582,7 @@ S2.define('select2/selection/multiple',[
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- var $selections = $();
|
|
|
|
|
|
+ var $selections = [];
|
|
|
|
|
|
for (var d = 0; d < data.length; d++) {
|
|
for (var d = 0; d < data.length; d++) {
|
|
var selection = data[d];
|
|
var selection = data[d];
|
|
@@ -1578,10 +1595,12 @@ S2.define('select2/selection/multiple',[
|
|
|
|
|
|
$selection.data('data', selection);
|
|
$selection.data('data', selection);
|
|
|
|
|
|
- $selections = $selections.add($selection);
|
|
|
|
|
|
+ $selections.push($selection);
|
|
}
|
|
}
|
|
|
|
|
|
- this.$selection.find('.select2-selection__rendered').append($selections);
|
|
|
|
|
|
+ var $rendered = this.$selection.find('.select2-selection__rendered');
|
|
|
|
+
|
|
|
|
+ Utils.appendMany($rendered, $selections);
|
|
};
|
|
};
|
|
|
|
|
|
return MultipleSelection;
|
|
return MultipleSelection;
|
|
@@ -3015,7 +3034,7 @@ S2.define('select2/data/select',[
|
|
};
|
|
};
|
|
|
|
|
|
SelectAdapter.prototype.addOptions = function ($options) {
|
|
SelectAdapter.prototype.addOptions = function ($options) {
|
|
- this.$element.append($options);
|
|
|
|
|
|
+ Utils.appendMany(this.$element, $options);
|
|
};
|
|
};
|
|
|
|
|
|
SelectAdapter.prototype.option = function (data) {
|
|
SelectAdapter.prototype.option = function (data) {
|
|
@@ -3185,7 +3204,7 @@ S2.define('select2/data/array',[
|
|
return self.item($(this)).id;
|
|
return self.item($(this)).id;
|
|
}).get();
|
|
}).get();
|
|
|
|
|
|
- var $options = $();
|
|
|
|
|
|
+ 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) {
|
|
@@ -3216,10 +3235,10 @@ S2.define('select2/data/array',[
|
|
if (item.children) {
|
|
if (item.children) {
|
|
var $children = this.convertToOptions(item.children);
|
|
var $children = this.convertToOptions(item.children);
|
|
|
|
|
|
- $option.append($children);
|
|
|
|
|
|
+ Utils.appendMany($option, $children);
|
|
}
|
|
}
|
|
|
|
|
|
- $options = $options.add($option);
|
|
|
|
|
|
+ $options.push($option);
|
|
}
|
|
}
|
|
|
|
|
|
return $options;
|
|
return $options;
|
|
@@ -3403,7 +3422,7 @@ S2.define('select2/data/tags',[
|
|
var $option = self.option(tag);
|
|
var $option = self.option(tag);
|
|
$option.attr('data-select2-tag', true);
|
|
$option.attr('data-select2-tag', true);
|
|
|
|
|
|
- self.addOptions($option);
|
|
|
|
|
|
+ self.addOptions([$option]);
|
|
|
|
|
|
self.insertTag(data, tag);
|
|
self.insertTag(data, tag);
|
|
}
|
|
}
|
|
@@ -5468,8 +5487,8 @@ S2.define('select2/compat/inputData',[
|
|
};
|
|
};
|
|
|
|
|
|
InputData.prototype.addOptions = function (_, $options) {
|
|
InputData.prototype.addOptions = function (_, $options) {
|
|
- var options = $.map($options, function (option) {
|
|
|
|
- return $.data(option, 'data');
|
|
|
|
|
|
+ var options = $.map($options, function ($option) {
|
|
|
|
+ return $.data($option[0], 'data');
|
|
});
|
|
});
|
|
|
|
|
|
this._currentData.push.apply(this._currentData, options);
|
|
this._currentData.push.apply(this._currentData, options);
|