Setup
There are 2 ways to initialise the select and the select multiple components.
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' },
);
Once created the new instance can be retrieved like this:
ECL.components.get(document.querySelector('[data-ecl-select-multiple]'));