View on GitHub

Celesta

Custom selectbox with look and feel of native one

Download this project as a .zip file Download this project as a tar.gz file

Events reference

Celesta can call your own callback when some events happen. Event handlers can be added with addEventListener method.

Celesta also passes arguments to callbacks of some events. Here is the generic example:

c.addEventListener('eventname', function (arg1, arg2, arg3) {
    // (do stuff)
});

A more specific example can be found here.

Here is the reference for event and arguments passed to callbacks.

Event Callback arguments Description
focus (none)

Celesta DOM element (or native select in fallback mode) obtains focus

blur (none)

Celesta DOM element (or native select in fallback mode) loses focus

open (none)

Celesta instance is opened (by user action or API function); only works in non-fallback mode

close (none)

Celesta instance is closed (by user action or API close)

change {string} new_value, {string|undefined} old_value, {string} new_text, {string} old_text, {number} new_index, {number|undefined} old_index

Option is selected (by user action or API function; same as optionselect, but has another arguments order

optionselect {number} new_index, {number|undefined} old_index, {string} new_value, {string|undefined} old_value, {string} new_text, {string} old_text

Option is selected (by user action or API function)

optionpreselect {number} new_index, {number|undefined} old_index, {string} new_value, {string|undefined} old_value, {string} new_text, {string} old_text

Option is pre-selected (by user action or API function); only works in non-fallback mode

optionhover {number} new_index, {number|undefined} old_index, {string} new_value, {string|undefined} old_value, {string} new_text, {string} old_text

Option is hovered/focused (by user action or API function); only works in non-fallback mode

refresh (none)

Celesta instance is refreshed, based on source <select>

destroy (none)

Celesta instance is destroyed