Constructor
new Select(element, options)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | DOM element for component instantiation and scope |
||||||||||||||||||||||||||||||||||||||||||
options |
Object |
Properties
|
Classes
Methods
destroy()
handleClickOnClearAll(e)
- Description:
Event callback to handle the click on the clear all button.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
Fires:
handleClickOption(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleClickOutside(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleClickSelectAll(e)
- Description:
Event callback to handle the click on the select all checkbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
Fires:
handleEsc(e)
- Description:
Event callback to handle different events which will close the dropdown.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleFocusout(e)
- Description:
Event callback to handle moving the focus out of the select.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleKeyboardOnClearAll(e)
- Description:
Event callback to handle keyboard events on the clear all button.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
Fires:
handleKeyboardOnClose(e)
- Description:
Event callback for handling keyboard events in the close button.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleKeyboardOnOption(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleKeyboardOnOptions(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleKeyboardOnSearch(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleKeyboardOnSelect(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleKeyboardOnSelectAll(e)
- Description:
Event callback to handle keyboard events on the select all checkbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
handleSearch(e)
- Description:
Event callback to handle the user typing in the search field.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
Fires:
handleToggle(e)
Parameters:
Name | Type | Description |
---|---|---|
e |
Event |
Fires:
init()
on(eventName, callback) → {void}
Example
// Registering a callback for the 'onToggle' event
select.on('onToggle', (event) => {
console.log('Toggle event occurred!', event);
});
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | The name of the event to listen for. |
callback |
function | The callback function to be invoked when the event occurs. |
Returns:
- Type
- void
resetForm()
- Description:
Event callback to reset the multiple select on form reset.
- Source:
setCurrentValue(values, opopt)
Example
// Replace current selection with new values
setCurrentValue(['value1', 'value2']);
// Add to current selection without clearing previous selections
setCurrentValue(['value3', 'value4'], 'add');
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
values |
string | Array.<string> | A string or an array of values or labels to set as selected. |
||
op |
string |
<optional> |
'replace'
|
The operation mode. Use 'add' to keep the previous selections. |
Throws:
-
Throws an error if an invalid operation mode is provided.
- Type
- Error
trigger(eventName, eventData)
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | The name of the event to trigger. |
eventData |
any | Data associated with the event. |
update(i)
Parameters:
Name | Type | Description |
---|---|---|
i |
Integer |
(static) autoInit(root) → {Select}
Parameters:
Name | Type | Description |
---|---|---|
root |
HTMLElement | DOM element for component instantiation and scope |
Returns:
An instance of Select.
- Type
- Select