diff --git a/docs/announcements-4.0.html b/docs/announcements-4.0.html index 5e107c57..8076ae7b 100644 --- a/docs/announcements-4.0.html +++ b/docs/announcements-4.0.html @@ -5,24 +5,6 @@ slug: announcements-4.0 ---
- The 4.0 release is ready for early adopters interested in testing it out.
- You can use the development version, available on GitHub, by getting the
- source code available in the select2-ng
branch. The source
- code can be
-
- downloaded as a zip
archive
- as well.
-
In Select2 4.0, the <select>
element supports all core
options, and support for the old
- <input type="hidden" />
has been removed. This means
+ <input type="hidden" />
has been deprecated. This means
that if you previously declared an AJAX field with some pre-selected
options that looked like...
- Will need to be recreated as a <select>
element with
+ It will need to be recreated as a <select>
element with
some <option>
tags that have value
attributes that match the old value.
+ So if your old code used a matcher that only displayed options if they + started with the term that was entered, it would look something like... +
+ ++function matchStart (term, text) { + if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) { + return true; + } + + return false; +} + +$("select").select2({ + matcher: matchStart +}) ++ +
+ Then in Select2 4.0, you would need to wrap the matchStart
+ method (or the name of the matcher you created) with a
+ oldMatcher
method that we have created.
+
+function matchStart (term, text) { + if (text.toUpperCase().indexOf(term.toUpperCase()) == 0) { + return true; + } + + return false; +} + +$.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { + $("select").select2({ + matcher: oldMatcher(matchStart) + }) +}); ++ +
+ This will work for any matchers that only took in the search term and the
+ text of the option as parameters. If your matcher relied on the third
+ parameter containing the jQuery element representing the original
+ <option>
tag, then you may need to slightly change
+ your matcher to expect the full JavaScript data object being passed in
+ instead. You can still retrieve the jQuery element from the data object
+ using the data.element
property.
+
@@ -263,9 +296,9 @@ $("select").select2({
And Select2 will automatically display the placeholder when the value of
- the select is -1
, which it is by default. This does not break
- the old functionality of Select2 where the placeholder option was blank by
- default.
+ the select is -1
, which it will be by default. This does not
+ break the old functionality of Select2 where the placeholder option was
+ blank by default.