diff --git a/docs/announcements-4.0.html b/docs/announcements-4.0.html index dbf17677..86eae3cf 100644 --- a/docs/announcements-4.0.html +++ b/docs/announcements-4.0.html @@ -98,6 +98,31 @@ slug: announcements-4.0

AMD-based build system

+ +

+ Select2 now uses an + AMD-based build system, + allowing for builds that only require the parts of Select2 that you need. + While a custom build system has not yet been created, Select2 is open + source and will gladly accept a pull request for one. +

+ +

+ Select2 includes the minimal almond + AMD loader, but a custom select2.amd.js build is available + if you already use an AMD loader. The code base (available in the + src directory) also uses AMD, allowing you to include Select2 + in your own build system and generate your own builds alongside your + existing infrastructure. +

+ +

+ The AMD methods used by Select2 are available as + jQuery.fn.select2.amd.define()/require(), allowing you to use the + included almond loader. These methods are primarily used by the + translations, but they are the recommended way to access custom modules + that Select2 provides. +

@@ -179,7 +204,8 @@ slug: announcements-4.0

A function has been created that allows old-style matcher functions to be converted to the new style. You can retrieve the function from the - select2/compat/matcher module. + select2/compat/matcher module, which should just wrap the old + matcher function.

More flexible placeholders

@@ -234,5 +260,54 @@ $("select").select2({ the old functionality of Select2 where the placeholder option was blank by default.

+ +

Display reflects the actual order of the values

+ +

+ In past versions of Select2, choices were displayed in the order that + they were selected. In cases where Select2 was used on a + <select> element, the order that the server recieved + the selections did not always match the order that the choices were + displayed, resulting in confusion in situations where the order is + important. +

+ +

+ Select2 will now order selected choices in the same order that will be + sent to the server. +

+ +

Deprecated and removed methods

+ +

+ As Select2 now uses a <select> element for all data + sources, a few methods that were available by calling + .select2() are no longer required. +

+ +

.select2("val")

+ +

+ The val method has been deprecated and will be removed in + Select2 4.1. The deprecated method no longer includes the + triggerChange parameter. +

+ +

+ You should directly call val on the underlying + <select> element instead. If you needed the second + parameter (triggerChange), you should also call + .trigger("change") on the element. +

+ +

.select2("enable")

+ +

+ Select2 will respect the disabled property of the underlying + select element. In order to enable or disable Select2, you should call + .prop('disabled', true/false) on the + <select> element. This method will be completely + removed in Select2 4.1. +

diff --git a/docs/examples.html b/docs/examples.html index ec4f668b..a815e1c4 100644 --- a/docs/examples.html +++ b/docs/examples.html @@ -332,8 +332,7 @@ $(".js-data-example-ajax").select2({ var $example = $(".js-example-programmatic"); var $exampleMulti = $(".js-example-programmatic-multi"); -// Recommended to use $e.val("CA").trigger("change"); -$(".js-programmatic-set-val").on("click", function () { $example.select2("val", "CA"); }); +$(".js-programmatic-set-val").on("click", function () { $example.val("CA").trigger("change"); }); $(".js-programmatic-open").on("click", function () { $example.select2("open"); }); $(".js-programmatic-close").on("click", function () { $example.select2("close"); }); @@ -341,9 +340,8 @@ $(".js-programmatic-close").on("click", function () { $example.select2("close"); $(".js-programmatic-init").on("click", function () { $example.select2(); }); $(".js-programmatic-destroy").on("click", function () { $example.select2("destroy"); }); -// Recommended to use $e.val(["CA", "AL"]).trigger("change"); -$(".js-programmatic-multi-set-val").on("click", function () { $exampleMulti.select2("val", ["CA", "AL"]); }); -$(".js-programmatic-multi-clear").on("click", function () { $exampleMulti.select2("val", null); }); +$(".js-programmatic-multi-set-val").on("click", function () { $exampleMulti.val(["CA", "AL"]).trigger("change"); }); +$(".js-programmatic-multi-clear").on("click", function () { $exampleMulti.val(null).trigger("change"); }); @@ -528,15 +526,15 @@ $(".js-example-language").select2({

 
-
+      $(".js-example-theme-multiple").select2({
+        theme: "classic"
+      });
+      
     
   
 
@@ -731,5 +729,13 @@ $.fn.select2.amd.require(
   $language.select2({
     language: "es"
   });
+
+  $(".js-example-theme-single").select2({
+    theme: "classic"
+  });
+
+  $(".js-example-theme-multiple").select2({
+    theme: "classic"
+  });
 });