Reference Source
public class | source

Events

You can directly use an instance of this class. events

Events helper.

Constructor Summary

Public Constructor
public

constructor(elementOrSelector: HTMLElement | String)

Method Summary

Public Methods
public

Destroy this instance, removing all events and references.

public

dispatch(eventName: String, options: Object): CustomEvent

Dispatch a custom event at the root element.

public

off(eventName: String, selector: String, handler: Function, useCapture: Boolean): Event

Remove an event listener.

public

on(eventName: String, selector: String, handler: Function, useCapture: Boolean): Events

Add an event listener.

Public Constructors

public constructor(elementOrSelector: HTMLElement | String) source

Params:

NameTypeAttributeDescription
elementOrSelector HTMLElement | String

The element or selector indicating the element to use as the delegation root.

Public Methods

public destroy() source

Destroy this instance, removing all events and references.

public dispatch(eventName: String, options: Object): CustomEvent source

Dispatch a custom event at the root element.

Params:

NameTypeAttributeDescription
eventName String

The name of the event to dispatch.

options Object
  • optional

CustomEvent options.

options.bubbles Object
  • optional
  • default: true

Whether the event should bubble.

options.cancelable Object
  • optional
  • default: true

Whether the event should be cancelable.

options.detail Object
  • optional

Data to pass to handlers as event.detail

Return:

CustomEvent

dispatched event.

public off(eventName: String, selector: String, handler: Function, useCapture: Boolean): Event source

Remove an event listener.

Params:

NameTypeAttributeDescription
eventName String
  • optional

The event name to stop listening for, including optional namespace(s).

selector String
  • optional

The selector that was used for event delegation.

handler Function
  • optional

The function that was passed to on().

useCapture Boolean
  • optional

Only remove listeners with useCapture set to the value passed in.

Return:

Event

this, chainable.

public on(eventName: String, selector: String, handler: Function, useCapture: Boolean): Events source

Add an event listener.

Params:

NameTypeAttributeDescription
eventName String

The event name to listen for, including optional namespace(s).

selector String
  • optional

The selector to use for event delegation.

handler Function

The function that will be called when the event is fired.

useCapture Boolean
  • optional

Whether or not to listen during the capturing or bubbling phase.

Return:

Events

this, chainable.