Select2 Cookbook

Curious as to how to get started with Select2? Looking for examples to learn all that Select2 can do? This is the place to look.

Coookbook on GitHub Select2 Website

View Basic
Basic select with a search box.
View Placeholders
Show a placeholder when no option is selected.
View Minimum input length
Do not start searching a data set when the search string is under a certain length.
View Maximum input length
Do not allow a data set to be searched if the search string is greater than a certain length.
View Templating results
Give a custom format to the results.
View Templating selections
Give a custom format to results when they are selected.
View Array data
Load the data set from a local array.
View Limit selection size
Limit the number of selections that can be made.
View Remote data
Load the data set from a remote data source.
View Infinite scroll
Lazy-load data from a remote data source.
View Tagging
Tagging allows users to create their own tags, or choose from a pre-defined list of tags.
View Tokenization
Allow choices to be automatically added as the user is typing into the search field after they press certain keys.
View Drag and drop sorting
Allow choices to be sorted using the jQuery UI sortable plugin
View Custom matcher for searching
Filter matches when searching using a custom function.
View Sort displayed results
Sort results using a custom sorting function.
View Duplicating tags
Allow for the same result to be selected multiple times.