API
Select
There are multiple labels contained in this component. You can set them in 2 ways: directly as a string or through data attributes. Textual values have precedence and if they are not provided, then DOM data attributes are used.
Parameters
elementHTMLElement DOM element for component instantiation and scopeoptionsObject (optional, default{})options.defaultTextString The default placeholder (optional, default'')options.searchTextString The label for search (optional, default'')options.selectAllTextString The label for select all (optional, default'')options.selectMultipleSelectorString The data attribute selector of the select multiple (optional, default'[data-ecl-select-multiple]')options.defaultTextAttributeString The data attribute for the default placeholder text (optional, default'data-ecl-select-default')options.searchTextAttributeString The data attribute for the default search text (optional, default'data-ecl-select-search')options.selectAllTextAttributeString The data attribute for the select all text (optional, default'data-ecl-select-all')options.noResultsTextAttributeString The data attribute for the no results options text (optional, default'data-ecl-select-no-results')options.closeLabelAttributeString The data attribute for the close button (optional, default'data-ecl-select-close')options.clearAllLabelAttributeString The data attribute for the clear all button (optional, default'data-ecl-select-clear-all')options.selectMultiplesSelectionCountSelectorString The selector for the counter of selected options (optional, default'ecl-select-multiple-selections-counter')options.closeButtonLabelString The label of the close button (optional, default'')options.clearAllButtonLabelString The label of the clear all button (optional, default'')options.noResultsText(optional, default'')
init
Initialise component.
destroy
Destroy component.
update
Update instance.
updateSelectionsCount
Parameters
iInteger
handleToggle
Parameters
eEvent
handleClickOption
Parameters
eEvent
handleClickSelectAll
Parameters
eEvent
handleFocusout
Parameters
eEvent
handleSearch
Parameters
eEvent
handleClickOutside
Parameters
eEvent
handleKeyboardOnSelect
Parameters
eEvent
handleKeyboardOnSelectAll
Parameters
eEvent
handleKeyboardOnOptions
Parameters
eEvent
handleKeyboardOnSearch
Parameters
eEvent
handleKeyboardOnOption
Parameters
eEvent
handleKeyboardOnClearAll
Parameters
eEvent
handleKeyboardOnClose
Parameters
eEvent
handleEsc
Parameters
eEvent
moveFocus
Parameters
upOrDown
handleClickOnClearAll
Parameters
eEvent Reset values of the Multiselect.
resetForm
Reset Multiselect.
autoInit
Parameters
rootHTMLElement DOM element for component instantiation and scopedefaultOptions(optional, default{})
Returns Select An instance of Select.
createSvgIcon
Parameters
iconclasses
Returns HTMLElement
createCheckbox
Parameters
Returns HTMLElement
createSelectIcon
Returns HTMLElement
checkCheckbox
Manually checks an ECL-specific checkbox when previously default has been prevented.
Parameters
eEvent
generateRandomId
Generate random string
Parameters
lengthnumber
Setup
There are 2 ways to initialise the select multiple component.
Automatic
Add data-ecl-auto-init="Select" attribute to component's markup:
Use the ECL library's autoInit() (ECL.autoInit()) when your page is ready or other custom event you want to hook onto.
Manual
Get target element, create an instance and invoke init().
Given you have 1 element with an attribute data-ecl-select-multiple on the page:
var elt = document.querySelector('[data-ecl-select-multiple]');
var select = new ECL.Select(elt);
select.init();
It's also possible to use the Select's autoInit method and pass specific labels for the element:
var select = ECL.Select.autoInit(
document.querySelector('[data-ecl-select-multiple]'),
{ defaultText: 'string', searchText: 'string', selectAllText: 'string' },
);