This is the first beta release of Select2 4.0.
You can view the 4.0 release announcement for a detailed look into the changes in Select2. This is a full rewrite of the core Select2 code.
New features
- Advanced plugin system that uses custom adapters
- AMD based build system
- Declarative configuration through
data-*
attributes - Easy to configure theme system and new default theme
Breaking changes
- Select2 now uses the MIT license
<select>
has replaced<input type="hidden" />
for all options (including remote data)- The
matcher
has been revamped to include full context, a compatibility module (select2/compat/matcher
) has been created - The display always reflects the order data is sent to the server
- The click mask is no longer the default (again). You can get back the old functionality by wrapping your
selectionAdapter
with theClickMask
(select2/selection/clickMask
) decorator.
Renamed options
formatSelection
->templateSelection
formatResult
->templateResult
sortResults
->sorter
ajax.jsonpCallback
->ajax.jsonp
ajax.results
->ajax.processResults
tags: [array,of,data]
->data: [array,of,data], tags: true
placeholderOption
has been replaced byplaceholder.id
(placeholder
->placeholder.text
)
Internationalization
formatNoMatches
->language.noMatches
formatSearching
->language.searching
formatInputTooShort
->language.inputTooShort
formatInputTooLong
->language.inputTooLong
formatAjaxError
->language.errorLoading
formatLoading
->language.loadingMore
formatSelectionTooBig
->language.maximumSelected
Renamed methods
.select2("val", [value])
->.val([value])
.select2("enable", !disabled)
->.prop("disabled", disabled)
Removed options
initSelection
- This is no longer needed with<select>
tags - Read more in the announcementid
- Data objects should now always haveid
andtext
attributes that are strings, use$.map
when migratingquery
- Use a custom data adapter instead - Read more in the announcementajax.params
- All parameters passed toajax
will be passed to the AJAX data transport function
Removed methods
.select2("onSortStart")
and.select2("onSortEnd")
- A custom selection adapter should be created instead.select2("data", data)
- Create the<option>
tags for the objects that you would like to set, and set the.val
to select them.select2("readonly")
- There is no way to make a<select>
element read-only, disable it instead