Fixed bug when destroying Select2
When destroying Select2, an error could be raised while destroying the selection container. This was because the destroy handler was relying on the container id being present. The old functionality has been restored where Select2 will destroy itself when it is initialized again.
This commit is contained in:
parent
ade7180d70
commit
85593de1fa
6
dist/js/select2.amd.full.js
vendored
6
dist/js/select2.amd.full.js
vendored
@ -660,6 +660,8 @@ define('select2/selection/base',[
|
||||
var id = container.id + '-container';
|
||||
var resultsId = container.id + '-results';
|
||||
|
||||
this.container = container;
|
||||
|
||||
this.$selection.attr('aria-owns', resultsId);
|
||||
|
||||
this.$selection.on('keydown', function (evt) {
|
||||
@ -716,7 +718,7 @@ define('select2/selection/base',[
|
||||
|
||||
BaseSelection.prototype.destroy = function () {
|
||||
// Unbind the dropdown click handler if it exists
|
||||
$(document.body).off('.select2.' + container.id);
|
||||
$(document.body).off('.select2.' + this.container.id);
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -3101,7 +3103,7 @@ define('select2/core',[
|
||||
], function ($, Options, Utils, KEYS) {
|
||||
var Select2 = function ($element, options) {
|
||||
if ($element.data('select2') != null) {
|
||||
return;
|
||||
$element.select2('destroy');
|
||||
}
|
||||
|
||||
this.$element = $element;
|
||||
|
6
dist/js/select2.amd.js
vendored
6
dist/js/select2.amd.js
vendored
@ -660,6 +660,8 @@ define('select2/selection/base',[
|
||||
var id = container.id + '-container';
|
||||
var resultsId = container.id + '-results';
|
||||
|
||||
this.container = container;
|
||||
|
||||
this.$selection.attr('aria-owns', resultsId);
|
||||
|
||||
this.$selection.on('keydown', function (evt) {
|
||||
@ -716,7 +718,7 @@ define('select2/selection/base',[
|
||||
|
||||
BaseSelection.prototype.destroy = function () {
|
||||
// Unbind the dropdown click handler if it exists
|
||||
$(document.body).off('.select2.' + container.id);
|
||||
$(document.body).off('.select2.' + this.container.id);
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -3101,7 +3103,7 @@ define('select2/core',[
|
||||
], function ($, Options, Utils, KEYS) {
|
||||
var Select2 = function ($element, options) {
|
||||
if ($element.data('select2') != null) {
|
||||
return;
|
||||
$element.select2('destroy');
|
||||
}
|
||||
|
||||
this.$element = $element;
|
||||
|
6
dist/js/select2.full.js
vendored
6
dist/js/select2.full.js
vendored
@ -10195,6 +10195,8 @@ define('select2/selection/base',[
|
||||
var id = container.id + '-container';
|
||||
var resultsId = container.id + '-results';
|
||||
|
||||
this.container = container;
|
||||
|
||||
this.$selection.attr('aria-owns', resultsId);
|
||||
|
||||
this.$selection.on('keydown', function (evt) {
|
||||
@ -10251,7 +10253,7 @@ define('select2/selection/base',[
|
||||
|
||||
BaseSelection.prototype.destroy = function () {
|
||||
// Unbind the dropdown click handler if it exists
|
||||
$(document.body).off('.select2.' + container.id);
|
||||
$(document.body).off('.select2.' + this.container.id);
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -12636,7 +12638,7 @@ define('select2/core',[
|
||||
], function ($, Options, Utils, KEYS) {
|
||||
var Select2 = function ($element, options) {
|
||||
if ($element.data('select2') != null) {
|
||||
return;
|
||||
$element.select2('destroy');
|
||||
}
|
||||
|
||||
this.$element = $element;
|
||||
|
4
dist/js/select2.full.min.js
vendored
4
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
6
dist/js/select2.js
vendored
6
dist/js/select2.js
vendored
@ -1088,6 +1088,8 @@ define('select2/selection/base',[
|
||||
var id = container.id + '-container';
|
||||
var resultsId = container.id + '-results';
|
||||
|
||||
this.container = container;
|
||||
|
||||
this.$selection.attr('aria-owns', resultsId);
|
||||
|
||||
this.$selection.on('keydown', function (evt) {
|
||||
@ -1144,7 +1146,7 @@ define('select2/selection/base',[
|
||||
|
||||
BaseSelection.prototype.destroy = function () {
|
||||
// Unbind the dropdown click handler if it exists
|
||||
$(document.body).off('.select2.' + container.id);
|
||||
$(document.body).off('.select2.' + this.container.id);
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -3529,7 +3531,7 @@ define('select2/core',[
|
||||
], function ($, Options, Utils, KEYS) {
|
||||
var Select2 = function ($element, options) {
|
||||
if ($element.data('select2') != null) {
|
||||
return;
|
||||
$element.select2('destroy');
|
||||
}
|
||||
|
||||
this.$element = $element;
|
||||
|
4
dist/js/select2.min.js
vendored
4
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
@ -42,6 +42,7 @@
|
||||
"grunt-contrib-uglify": "~0.4.0",
|
||||
"grunt-contrib-watch": "~0.6.0",
|
||||
"grunt-gh-pages": "^0.9.1",
|
||||
"grunt-jekyll": "^0.4.2",
|
||||
"grunt-sass": "~0.12.0",
|
||||
"node-sass": "~0.8.6"
|
||||
}
|
||||
|
2
src/js/select2/core.js
vendored
2
src/js/select2/core.js
vendored
@ -6,7 +6,7 @@ define([
|
||||
], function ($, Options, Utils, KEYS) {
|
||||
var Select2 = function ($element, options) {
|
||||
if ($element.data('select2') != null) {
|
||||
return;
|
||||
$element.select2('destroy');
|
||||
}
|
||||
|
||||
this.$element = $element;
|
||||
|
4
src/js/select2/selection/base.js
vendored
4
src/js/select2/selection/base.js
vendored
@ -21,6 +21,8 @@ define([
|
||||
var id = container.id + '-container';
|
||||
var resultsId = container.id + '-results';
|
||||
|
||||
this.container = container;
|
||||
|
||||
this.$selection.attr('aria-owns', resultsId);
|
||||
|
||||
this.$selection.on('keydown', function (evt) {
|
||||
@ -77,7 +79,7 @@ define([
|
||||
|
||||
BaseSelection.prototype.destroy = function () {
|
||||
// Unbind the dropdown click handler if it exists
|
||||
$(document.body).off('.select2.' + container.id);
|
||||
$(document.body).off('.select2.' + this.container.id);
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
|
Loading…
Reference in New Issue
Block a user