소스 검색

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.
Kevin Brown 10 년 전
부모
커밋
85593de1fa
9개의 변경된 파일21개의 추가작업 그리고 10개의 파일을 삭제
  1. 4 2
      dist/js/select2.amd.full.js
  2. 4 2
      dist/js/select2.amd.js
  3. 4 2
      dist/js/select2.full.js
  4. 0 0
      dist/js/select2.full.min.js
  5. 4 2
      dist/js/select2.js
  6. 0 0
      dist/js/select2.min.js
  7. 1 0
      package.json
  8. 1 1
      src/js/select2/core.js
  9. 3 1
      src/js/select2/selection/base.js

+ 4 - 2
dist/js/select2.amd.full.js

@@ -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;

+ 4 - 2
dist/js/select2.amd.js

@@ -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;

+ 4 - 2
dist/js/select2.full.js

@@ -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;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.full.min.js


+ 4 - 2
dist/js/select2.js

@@ -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;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
dist/js/select2.min.js


+ 1 - 0
package.json

@@ -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"
   }

+ 1 - 1
src/js/select2/core.js

@@ -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;

+ 3 - 1
src/js/select2/selection/base.js

@@ -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) {

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.