width option now supports various strategies instead of always being copied from the source element
Clicks on a label associated with the source element are now redirected to Select2.
val will now only accept ids, if you want to specify the full object for the selection use the new data method instead. val will also now only work on non-selects if initSelection was specified.
+
It is now possible to limit the number of options that can be selected in a multi-select component. See the Maximum Selection Size example
@@ -246,7 +248,7 @@ $("#e10_3").select2({
-
+
Examples
@@ -344,7 +346,7 @@ $("#e10_3").select2({
-
+
Multi-Value Select Boxes
Select2 also supports multi-value select boxes. The select below is declared with the multiple attribute. Select2 automatially picks up on this:
@@ -392,7 +394,7 @@ $("#e2_2").select2({
-
+
Minimum Input
Select2 supports a minimum input setting which is useful for large remote datasets where short search terms are not very useful:
@@ -436,7 +438,7 @@ $("#e2_2").select2({
-
+
Loading Data
Select2 uses a function to load result data. Here is a trivial example that creates choices that consist of user's input repeated a number of times:
@@ -452,6 +454,28 @@ $("#e2_2").select2({
+
+
+
+
+
Maximum Selection Size
+
Select2 allows the developer to limit the number of items that can be selected in a multi-select control.
+ In the example below only 3 or less items can be selected.
+
+
+
+
+
+
Example Code
+
+
+
+
+
Loading Array Data
@@ -476,7 +500,7 @@ $("#e2_2").select2({
-
+
Loading Remote Data
Select2 comes with AJAX/JSONP support built in. In this example we will search for a movie using Rotten Tomatoes API: