Expandable

Expandable

new Expandable(element, options)

Source:
Parameters:
NameTypeDescription
elementHTMLElement

DOM element for component instantiation and scope

optionsObject
Properties
NameTypeDescription
toggleSelectorString

Selector for toggling element

labelSelectorString

Selector for label

labelExpandedString

Label state

labelCollapsedString

Label collapsed state

attachClickListenerBoolean

Whether or not to bind click events on toggle

Classes

Expandable

Methods

destroy()

Description:
  • Destroy component.

Source:

handleClickOnToggle()

Description:
  • Toggles between collapsed/expanded states.

Source:
Fires:
  • Expandable#event:handleToggle

init()

Description:
  • Initialise component.

Source:

on(eventName, callback) → {void}

Description:
  • Register a callback function for a specific event.

Source:
Example
// Registering a callback for the 'onToggle' event
expandable.on('onToggle', (event) => {
  console.log('Toggle event occurred!', event);
});
Parameters:
NameTypeDescription
eventNamestring

The name of the event to listen for.

callbackfunction

The callback function to be invoked when the event occurs.

Returns:
Type
void

trigger(eventName, eventData)

Description:
  • Trigger a component event.

Source:
Parameters:
NameTypeDescription
eventNamestring

The name of the event to trigger.

eventDataany

Data associated with the event.

(static) autoInit(root) → {Expandable}

Source:
Parameters:
NameTypeDescription
rootHTMLElement

DOM element for component instantiation and scope

Returns:

An instance of Expandable.

Type
Expandable

Events

onToggle

Description:
  • An array of supported events for this component.

Source:
Type:
  • Array.<string>