Prechádzať zdrojové kódy

Added `dropdownParent`

`dropdownParent` controls the location of the dropdown when it is
automatically added to the DOM. By default, this is the body
element but it can be modified based on where the user needs it.
Kevin Brown 11 rokov pred
rodič
commit
f6625d2347

+ 5 - 3
dist/js/select2.amd.full.js

@@ -742,7 +742,7 @@ define('select2/selection/base',[
   };
 
   BaseSelection.prototype.destroy = function () {
-    this._detachCloseHandler();
+    this._detachCloseHandler(this.container);
   };
 
   BaseSelection.prototype.update = function (data) {
@@ -2851,6 +2851,8 @@ define('select2/dropdown/attachBody',[
 
 ], function () {
   function AttachBody (decorated, $element, options) {
+    this.$dropdownParent = options.get('dropdownParent') || document.body;
+
     decorated.call(this, $element, options);
   }
 
@@ -2981,7 +2983,7 @@ define('select2/dropdown/attachBody',[
   };
 
   AttachBody.prototype._showDropdown = function (decorated) {
-    this.$dropdownContainer.appendTo(document.body);
+    this.$dropdownContainer.appendTo(this.$dropdownParent);
 
     this._positionDropdown();
   };
@@ -3323,7 +3325,7 @@ define('select2/core',[
 ], function ($, Options, Utils, KEYS) {
   var Select2 = function ($element, options) {
     if ($element.data('select2') != null) {
-      $element.select2('destroy');
+      $element.data('select2').destroy();
     }
 
     this.$element = $element;

+ 5 - 3
dist/js/select2.amd.js

@@ -742,7 +742,7 @@ define('select2/selection/base',[
   };
 
   BaseSelection.prototype.destroy = function () {
-    this._detachCloseHandler();
+    this._detachCloseHandler(this.container);
   };
 
   BaseSelection.prototype.update = function (data) {
@@ -2851,6 +2851,8 @@ define('select2/dropdown/attachBody',[
 
 ], function () {
   function AttachBody (decorated, $element, options) {
+    this.$dropdownParent = options.get('dropdownParent') || document.body;
+
     decorated.call(this, $element, options);
   }
 
@@ -2981,7 +2983,7 @@ define('select2/dropdown/attachBody',[
   };
 
   AttachBody.prototype._showDropdown = function (decorated) {
-    this.$dropdownContainer.appendTo(document.body);
+    this.$dropdownContainer.appendTo(this.$dropdownParent);
 
     this._positionDropdown();
   };
@@ -3323,7 +3325,7 @@ define('select2/core',[
 ], function ($, Options, Utils, KEYS) {
   var Select2 = function ($element, options) {
     if ($element.data('select2') != null) {
-      $element.select2('destroy');
+      $element.data('select2').destroy();
     }
 
     this.$element = $element;

+ 5 - 3
dist/js/select2.full.js

@@ -10277,7 +10277,7 @@ define('select2/selection/base',[
   };
 
   BaseSelection.prototype.destroy = function () {
-    this._detachCloseHandler();
+    this._detachCloseHandler(this.container);
   };
 
   BaseSelection.prototype.update = function (data) {
@@ -12386,6 +12386,8 @@ define('select2/dropdown/attachBody',[
 
 ], function () {
   function AttachBody (decorated, $element, options) {
+    this.$dropdownParent = options.get('dropdownParent') || document.body;
+
     decorated.call(this, $element, options);
   }
 
@@ -12516,7 +12518,7 @@ define('select2/dropdown/attachBody',[
   };
 
   AttachBody.prototype._showDropdown = function (decorated) {
-    this.$dropdownContainer.appendTo(document.body);
+    this.$dropdownContainer.appendTo(this.$dropdownParent);
 
     this._positionDropdown();
   };
@@ -12858,7 +12860,7 @@ define('select2/core',[
 ], function ($, Options, Utils, KEYS) {
   var Select2 = function ($element, options) {
     if ($element.data('select2') != null) {
-      $element.select2('destroy');
+      $element.data('select2').destroy();
     }
 
     this.$element = $element;

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/js/select2.full.min.js


+ 5 - 3
dist/js/select2.js

@@ -1170,7 +1170,7 @@ define('select2/selection/base',[
   };
 
   BaseSelection.prototype.destroy = function () {
-    this._detachCloseHandler();
+    this._detachCloseHandler(this.container);
   };
 
   BaseSelection.prototype.update = function (data) {
@@ -3279,6 +3279,8 @@ define('select2/dropdown/attachBody',[
 
 ], function () {
   function AttachBody (decorated, $element, options) {
+    this.$dropdownParent = options.get('dropdownParent') || document.body;
+
     decorated.call(this, $element, options);
   }
 
@@ -3409,7 +3411,7 @@ define('select2/dropdown/attachBody',[
   };
 
   AttachBody.prototype._showDropdown = function (decorated) {
-    this.$dropdownContainer.appendTo(document.body);
+    this.$dropdownContainer.appendTo(this.$dropdownParent);
 
     this._positionDropdown();
   };
@@ -3751,7 +3753,7 @@ define('select2/core',[
 ], function ($, Options, Utils, KEYS) {
   var Select2 = function ($element, options) {
     if ($element.data('select2') != null) {
-      $element.select2('destroy');
+      $element.data('select2').destroy();
     }
 
     this.$element = $element;

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
dist/js/select2.min.js


+ 1 - 1
docs/options.html

@@ -467,7 +467,7 @@ ajax: {
           <dd><code>dropdownParent</code></dd>
 
           <dt>Value</dt>
-          <dd>jQuery element</dd>
+          <dd>jQuery element or DOM node</dd>
 
           <hr />
 

+ 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) {
-      $element.select2('destroy');
+      $element.data('select2').destroy();
     }
 
     this.$element = $element;

+ 3 - 1
src/js/select2/dropdown/attachBody.js

@@ -2,6 +2,8 @@ define([
 
 ], function () {
   function AttachBody (decorated, $element, options) {
+    this.$dropdownParent = options.get('dropdownParent') || document.body;
+
     decorated.call(this, $element, options);
   }
 
@@ -132,7 +134,7 @@ define([
   };
 
   AttachBody.prototype._showDropdown = function (decorated) {
-    this.$dropdownContainer.appendTo(document.body);
+    this.$dropdownContainer.appendTo(this.$dropdownParent);
 
     this._positionDropdown();
   };

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

@@ -98,7 +98,7 @@ define([
   };
 
   BaseSelection.prototype.destroy = function () {
-    this._detachCloseHandler();
+    this._detachCloseHandler(this.container);
   };
 
   BaseSelection.prototype.update = function (data) {

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov