Skip to content

Commit e23b8b5

Browse files
committed
More work on the announcement
1 parent 096d55b commit e23b8b5

2 files changed

Lines changed: 95 additions & 14 deletions

File tree

docs/announcements-4.0.html

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,31 @@ <h2>Plugin system</h2>
9898

9999
<section id="amd-builds">
100100
<h2>AMD-based build system</h2>
101+
102+
<p>
103+
Select2 now uses an
104+
<a href="https://en.wikipedia.org/wiki/Asynchronous_module_definition">AMD-based build system</a>,
105+
allowing for builds that only require the parts of Select2 that you need.
106+
While a custom build system has not yet been created, Select2 is open
107+
source and will gladly accept a pull request for one.
108+
</p>
109+
110+
<p>
111+
Select2 includes the minimal <a href="https://github.com/jrburke/almond">almond</a>
112+
AMD loader, but a custom <code>select2.amd.js</code> build is available
113+
if you already use an AMD loader. The code base (available in the
114+
<code>src</code> directory) also uses AMD, allowing you to include Select2
115+
in your own build system and generate your own builds alongside your
116+
existing infrastructure.
117+
</p>
118+
119+
<p>
120+
The AMD methods used by Select2 are available as
121+
<code>jQuery.fn.select2.amd.define()/require()</code>, allowing you to use the
122+
included almond loader. These methods are primarily used by the
123+
translations, but they are the recommended way to access custom modules
124+
that Select2 provides.
125+
</p>
101126
</section>
102127

103128
<section id="migrating">
@@ -179,7 +204,8 @@ <h2 id="new-matcher">Advanced matching of searches</h2>
179204
<p>
180205
A function has been created that allows old-style matcher functions to be
181206
converted to the new style. You can retrieve the function from the
182-
<code>select2/compat/matcher</code> module.
207+
<code>select2/compat/matcher</code> module, which should just wrap the old
208+
matcher function.
183209
</p>
184210

185211
<h2 id="flexible-placeholders">More flexible placeholders</h2>
@@ -234,5 +260,54 @@ <h2 id="flexible-placeholders">More flexible placeholders</h2>
234260
the old functionality of Select2 where the placeholder option was blank by
235261
default.
236262
</p>
263+
264+
<h2 id="value-ordering">Display reflects the actual order of the values</h2>
265+
266+
<p>
267+
In past versions of Select2, choices were displayed in the order that
268+
they were selected. In cases where Select2 was used on a
269+
<code>&lt;select&gt;</code> element, the order that the server recieved
270+
the selections did not always match the order that the choices were
271+
displayed, resulting in confusion in situations where the order is
272+
important.
273+
</p>
274+
275+
<p>
276+
Select2 will now order selected choices in the same order that will be
277+
sent to the server.
278+
</p>
279+
280+
<h2 id="removed-methods">Deprecated and removed methods</h2>
281+
282+
<p>
283+
As Select2 now uses a <code>&lt;select&gt;</code> element for all data
284+
sources, a few methods that were available by calling
285+
<code>.select2()</code> are no longer required.
286+
</p>
287+
288+
<h3>.select2("val")</h3>
289+
290+
<p>
291+
The <code>val</code> method has been deprecated and will be removed in
292+
Select2 4.1. The deprecated method no longer includes the
293+
<code>triggerChange</code> parameter.
294+
</p>
295+
296+
<p>
297+
You should directly call <code>val</code> on the underlying
298+
<code>&lt;select&gt;</code> element instead. If you needed the second
299+
parameter (<code>triggerChange</code>), you should also call
300+
<code>.trigger("change")</code> on the element.
301+
</p>
302+
303+
<h3>.select2("enable")</h3>
304+
305+
<p>
306+
Select2 will respect the <code>disabled</code> property of the underlying
307+
select element. In order to enable or disable Select2, you should call
308+
<code>.prop('disabled', true/false)</code> on the
309+
<code>&lt;select&gt;</code> element. This method will be completely
310+
removed in Select2 4.1.
311+
</p>
237312
</section>
238313
</div>

docs/examples.html

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -332,18 +332,16 @@ <h2>Example code</h2>
332332
var $example = $(".js-example-programmatic");
333333
var $exampleMulti = $(".js-example-programmatic-multi");
334334

335-
// Recommended to use $e.val("CA").trigger("change");
336-
$(".js-programmatic-set-val").on("click", function () { $example.select2("val", "CA"); });
335+
$(".js-programmatic-set-val").on("click", function () { $example.val("CA").trigger("change"); });
337336

338337
$(".js-programmatic-open").on("click", function () { $example.select2("open"); });
339338
$(".js-programmatic-close").on("click", function () { $example.select2("close"); });
340339

341340
$(".js-programmatic-init").on("click", function () { $example.select2(); });
342341
$(".js-programmatic-destroy").on("click", function () { $example.select2("destroy"); });
343342

344-
// Recommended to use $e.val(["CA", "AL"]).trigger("change");
345-
$(".js-programmatic-multi-set-val").on("click", function () { $exampleMulti.select2("val", ["CA", "AL"]); });
346-
$(".js-programmatic-multi-clear").on("click", function () { $exampleMulti.select2("val", null); });
343+
$(".js-programmatic-multi-set-val").on("click", function () { $exampleMulti.val(["CA", "AL"]).trigger("change"); });
344+
$(".js-programmatic-multi-clear").on("click", function () { $exampleMulti.val(null).trigger("change"); });
347345
</script>
348346
</div>
349347
</section>
@@ -528,15 +526,15 @@ <h2>Example code</h2>
528526

529527
<pre data-fill-from=".js-code-theme"></pre>
530528

531-
<script type="text/javascript" class="js-code-theme">
532-
$(".js-example-theme-single").select2({
533-
theme: "classic"
534-
});
529+
<script type="text/x-example-code" class="js-code-theme">
530+
$(".js-example-theme-single").select2({
531+
theme: "classic"
532+
});
535533

536-
$(".js-example-theme-multiple").select2({
537-
theme: "classic"
538-
});
539-
</script>
534+
$(".js-example-theme-multiple").select2({
535+
theme: "classic"
536+
});
537+
</script>
540538
</div>
541539
</section>
542540
</div>
@@ -731,5 +729,13 @@ <h2>Example code</h2>
731729
$language.select2({
732730
language: "es"
733731
});
732+
733+
$(".js-example-theme-single").select2({
734+
theme: "classic"
735+
});
736+
737+
$(".js-example-theme-multiple").select2({
738+
theme: "classic"
739+
});
734740
});
735741
</script>

0 commit comments

Comments
 (0)