Select2
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
Official documentation
For more detailed information and examples, see the official documentation: Select2.js.
How to use?
Copy-paste the stylesheets <link>
into your <head>
to load the
CSS.
Copy-paste the following <script>
near the end of your pages under JS
Implementing Plugins to enable it.
Copy-paste the following <script>
near the end of your pages under JS
Nova to enable it.
Copy-paste the init function under JS Plugins Init., before the closing </body>
tag, to enable it.
Basic examples
Use data-placeholder="..."
attribute
Use .custom-select-without-bordered
class for data-classes=""
attribute
Use multiple
and data-is-hide-search="true"
attributes for disable search
- ×Life
Use <optgroup>
tag
Use .input-group-prepend
and .input-group-append
classes
Use disabled
attrubute
With icon/image
Use data-placeholder='<span><i class="nova-user mr-2"></i> Select member</span>'
Use data-option-template='HTML here...'

Validation states
For more inforamation about form validation your can read on Validation page
Methods
Options can be passed via data attributes or JavaScript. For data attributes, append the option name
to data-
, as in data-placeholder=""
.
Attribute | Description |
---|---|
data-placeholder |
defines a placeholder select. In this case, you must specify an empty option tag,
which must be left first, and there should also be no option tags selected using the
selected attribute.
|
data-width |
By default select width equal 100%, you can set suctom width data-width="auto" or data-width="300px" etc...
|
data-classes |
custom classes that will be added to the tag with the class .select2-selection .
|
data-dropdown-classes |
custom classes that will be added to the drop-down list. |
data-is-hide-search |
if true , then search by items is not displayed. |
data-tags |
if true , selected options will be show as tags. |