Select Options
The Select Options API of Better-Nice-Select
Default Settings
You can change the default settings for better-nice-select by modifying betterNiceSelect.DEFAULTS
object as example:
animation
- Attribute:
data-animation
- Type:
Boolean
- Detail:
Set to
false
if you do not want to have animation effects. - Default:
true
- Example: Animation
customOptiongroupLabels
- Attribute:
data-custom-optiongroup-labels
- Type:
String
|Function
- Detail:
Used to load the optiongroups for a select field if you do not want to prerender them in the HTML. The function needs to return elements in a
string[]
to work properly. - Default:
undefined
- Example: Custom Optiongroup Labels
customSearch
- Attribute:
data-custom-search
- Type:
String
|Function
- Detail: Used to load the select field data for adding new items. The function needs to return elements in a specific JSON format to work properly.
- Default:
undefined
- Example: Remote Data
customTagCheck
- Attribute:
data-custom-tag-check
- Type:
String
|Function
- Detail:
Used to add some logic to the select field to return a
Boolean
if an invalid value is entered. - Default:
undefined
- Example: Constraining Tag Creation
disabled
- Attribute:
disabled="disabled"
- Type:
String
- Detail:
You can disable the whole
<select>
component so you can not add or delete already selected<option>
tags. You can also disable single<option>
tags to add them and make them unremovable. Works withdata-custom-search
- JSON format needs to be expanded withdisabled: true
as attribute for a singleitem
. Default isdisabled: false
and does not need to be added. - Default:
undefined
- Example: From HTML
init
- Attribute:
data-toggle
- Type:
String
- Detail: Activate better-nice-select with HTML after adding a bit of JavaScript.
- Default:
'better-nice-select'
- Example: From HTML
icons
- Attribute:
data-icons
- Type:
Object
- Detail: Set own custom icons via Javascript or HTML for the placeholder icons.
- Default:
- Example: Icons
inputDelay
- Attribute:
data-input-delay
- Type:
Number
- Detail: Debounce functionality of the search input in ms
- Default: 400
- Example: Input Delay
locale
- Attribute:
data-locale
- Type:
String
- Detail:
Sets the locale to use (i.e.
'de-DE'
). Locale files currently all inside file and do not need to be pre-loaded. If leftundefined
, an empty string or a locale which is not allowed, errors are thrown. - Default:
'en-US'
- Example: Locale
scrollable
on
- Attribute:
data-scrollable-on
- Type:
Boolean
- Detail:
Set
true
to enable virtual scroll to display a virtual, “infinite” list. Needsdata-scrollable-height
to be set to work. - Default:
false
- Example: Scrollable
height
- Attribute:
data-scrollable-height
- Type:
String
- Detail:
Set a valid CSS
height
to display a virtual, “infinite” list. Needsdata-scrollable-on
to be set to work. - Default:
undefined
- Example: Scrollable
tags
- Attribute:
data-tags
- Type:
Boolean
- Detail:
Set
true
to enable dynamic item creation on input search field with pressing “,” or “Enter”. The separators that should be used when tokenizing can be specified using thetokenSeparators
option. - Default:
false
- Example: Tagging
tokenSeparators
- Attribute:
data-token-separators
- Type:
Array
- Detail: The separators that should be used when tokenizing.
- Default:
[",", "Enter"]
- Example: Token Separators