This feature requires the plugin files js/developr.input.js and css/styles/form.css
The template form plugin provides a replacement style for selects, for a uniform styling accross browsers and platforms. To use it, just add the class select to any select element:
<select class="select">
...
</select>
Select are focusable, and work with keyboard shortcuts too: up and down arrows to navigate in the values list, enter to select, type any text to scroll to the first matching value. On touch devices, the default UI is used (unless it is disabled with an option - see reference below for more details)
As most form elements, selects can be disabled, either by disabling the original select or by adding the class disabled.
Since v1.3, the select can embed a serach field that display over the selected value when the select opens. By default, it is automatically used if the select has more than 40 values, and you can control when to show it using the following options: searchField, searchIfMoreThan and searchText (see reference below for more details).
Dynamic changes
If you change the value of the select with javascript, you need to tell the styling plugin that it has changed: just fire a change event:
$(selector).change();
And if you change the option's list, trigger the corresponding special event to force a refresh:
$(selector).trigger('update-select-list');
Both events can be chained if both options list and value have changed:
As any other element, selects can use the 9 color sets:
Open on hover
By default, selects open when the user clicks the down arrow, but they may also open on hover: just add the class auto-open.
<select class="select auto-open">
...
</select>
Expandable list
On the default select style, the list has the same width as the whole select, but if you want the list to expand (for long texts) add the class expandable-list.
You may control the number of visible elements using the size attribute.
Easy multiple selection
Multiple selects work like standard multiple selects, holding Ctrl or Cmd to select several values. To make it easier for users to select multiple values, add the class easy-multiple-selection, and the selection can be done only by clicking (note that this is the default behavior on touch devices)
It is possible to use the drop-down style without any underlying select element: just build the corresponding markup, and the plugin will handle it as well:
The tabindex attribute is used to make the element focusable
Note that most styling options will work as well.
Options reference
The defaults may be modified at runtime in $.fn.styleSelect.defaults, and options may be passed inline using the data-select-options attribute
styledList
False to use system's drop-down UI, true to use style's drop-downs Type: boolean|null Default: true
styledOnTouch
For touch devices: false to use system's drop-down UI, true to use style's drop-downs, or null to guess (true for check-list style, false for others)
Note: only works if styledList is true Type: boolean|null Default: null
openOnKeyDown
When focused, should the arrow down key open the drop-down or just scroll values? Type: boolean Default: true
noValueText
Text for multiple select with no value selected Type: string Default: ''
singleValueText
Text for multiple select with one value selected, or false to just display the selected value Type: string|boolean Default: false
multipleValuesText
Text for multiple select with multiple values selected, or false to just display the selected list
Tip: use %d as a placeholder for the number of values Type: string|boolean Default: '%d selected'
allValuesText
Text for multiple select with all values selected, or false to just display the selected list
Tip: use %d as a placeholder for the number of values Type: string|boolean Default: 'All'
searchField
Enable search field when open - use null to automatically use when list has more than searchIfMoreThan elements Type: boolean|null Default: null
searchIfMoreThan
Minimum number of elements to trigger a search field, if searchField is null Type: int Default: 40
searchText
Helper text for seach field Type: string Default: 'Search'