Skip to main content

Class: MultiSelect

A class to convert a native select element into a multi-select that resembles a native select element.

Constructors

constructor

new MultiSelect(selectElement, onChangeCallback?)

Creates a new MultiSelect

Parameters

NameTypeDefault valueDescription
selectElementHTMLSelectElementundefinedThe native select element to convert to a multi-select
onChangeCallbacknull | onChangeCallbacknull(Optional) The callback function to call when the selected values change. The function will be passed the multi-select id and an array of selected values

Accessors

id

get id(): string

Gets the id of the multi-select.

Returns

string

Returns the id of the multi-select


selectedValues

get selectedValues(): string[]

Gets the currently selected values.

Returns

string[]

Returns an array of selected values

Methods

registerOnChangeCallback

registerOnChangeCallback(onChangeCallback): void

Registers a callback function to be called when the selected values change

Parameters

NameTypeDescription
onChangeCallbackonChangeCallbackThe function to call. The function will be passed the multi-select id and an array of selected values

Returns

void