|
@@ -10055,6 +10055,10 @@ define('select2/results',[
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ Results.prototype.destroy = function () {
|
|
|
+ this.$results.remove();
|
|
|
+ };
|
|
|
+
|
|
|
Results.prototype.ensureHighlightVisible = function () {
|
|
|
var $highlighted = this.$results.find('.highlighted');
|
|
|
|
|
@@ -10139,6 +10143,11 @@ define('select2/selection/base',[
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ BaseSelection.prototype.destroy = function () {
|
|
|
+ // Unbind the dropdown click handler if it exists
|
|
|
+ $(document.body).off('.select2.' + container.id);
|
|
|
+ };
|
|
|
+
|
|
|
BaseSelection.prototype.update = function (data) {
|
|
|
throw new Error('The `update` method must be defined in child classes.');
|
|
|
};
|
|
@@ -10496,6 +10505,10 @@ define('select2/data/base',[
|
|
|
// Can be implemented in subclasses
|
|
|
};
|
|
|
|
|
|
+ BaseAdapter.prototype.destroy = function () {
|
|
|
+ // Can be implemented in subclasses
|
|
|
+ };
|
|
|
+
|
|
|
BaseAdapter.prototype.generateResultId = function (container, data) {
|
|
|
var id = container.id + '-result-';
|
|
|
|
|
@@ -10609,6 +10622,14 @@ define('select2/data/select',[
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ SelectAdapter.prototype.destroy = function () {
|
|
|
+ // Remove anything added to child elements
|
|
|
+ this.$element.find('*').each(function () {
|
|
|
+ // Remove any custom data set by Select2
|
|
|
+ $.removeData(this, 'data');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
SelectAdapter.prototype.query = function (params, callback) {
|
|
|
var data = [];
|
|
|
var self = this;
|
|
@@ -11014,9 +11035,16 @@ define('select2/dropdown',[
|
|
|
'</span>'
|
|
|
);
|
|
|
|
|
|
+ this.$dropdown = $dropdown;
|
|
|
+
|
|
|
return $dropdown;
|
|
|
};
|
|
|
|
|
|
+ Dropdown.prototype.destroy = function () {
|
|
|
+ // Remove the dropdown from the DOM
|
|
|
+ this.$dropdown.remove();
|
|
|
+ };
|
|
|
+
|
|
|
Dropdown.prototype.bind = function (container, $container) {
|
|
|
// Can be implemented in subclasses
|
|
|
};
|
|
@@ -11485,6 +11513,10 @@ define('select2/core',[
|
|
|
'./keys'
|
|
|
], function ($, Options, Utils, KEYS) {
|
|
|
var Select2 = function ($element, options) {
|
|
|
+ if ($element.data('select2') != null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
this.$element = $element;
|
|
|
|
|
|
this.id = this._generateId($element);
|
|
@@ -11553,6 +11585,9 @@ define('select2/core',[
|
|
|
// Hide the original select
|
|
|
|
|
|
$element.hide();
|
|
|
+
|
|
|
+ this._tabindex = $element.attr('tabindex') || 0;
|
|
|
+
|
|
|
$element.attr('tabindex', '-1');
|
|
|
|
|
|
$element.data('select2', this);
|
|
@@ -11609,7 +11644,7 @@ define('select2/core',[
|
|
|
Select2.prototype._registerDomEvents = function () {
|
|
|
var self = this;
|
|
|
|
|
|
- this.$element.on('change', function () {
|
|
|
+ this.$element.on('change.select2', function () {
|
|
|
self.data.current(function (data) {
|
|
|
self.trigger('selection:update', {
|
|
|
data: data
|
|
@@ -11786,6 +11821,26 @@ define('select2/core',[
|
|
|
return this.$container.hasClass('open');
|
|
|
};
|
|
|
|
|
|
+ Select2.prototype.destroy = function () {
|
|
|
+ this.$container.remove();
|
|
|
+
|
|
|
+ this.$element.off('.select2');
|
|
|
+ this.$element.attr('tabindex', this._tabindex);
|
|
|
+
|
|
|
+ this.$element.show();
|
|
|
+ this.$element.removeData('select2');
|
|
|
+
|
|
|
+ this.data.destroy();
|
|
|
+ this.selection.destroy();
|
|
|
+ this.dropdown.destroy();
|
|
|
+ this.results.destroy();
|
|
|
+
|
|
|
+ this.data = null;
|
|
|
+ this.selection = null;
|
|
|
+ this.dropdown = null;
|
|
|
+ this.results = null;
|
|
|
+ };
|
|
|
+
|
|
|
Select2.prototype.render = function () {
|
|
|
var $container = $(
|
|
|
'<span class="select2 select2-container select2-theme-default">' +
|