Constructor
new Event()
Provides simplified event handling for DOM nodes. Used as a mixin into RapidContext.Widget instances and similar, but also provides static versions of the same functions.
- Source:
- rapidcontext/ui/event.mjs, line 17
Methods
emit(event, optsopt) → {boolean}
Dispatches a single event from this DOM node. Also creates a new CustomEvent instance if needed.
- Parameters:
-
Name Type Attributes Description event
{string/Event} the event type name or instance opts
{Object} <optional>
the event options Properties
Name Type Attributes Default Description async
{boolean} <optional>
true the async dispatch flag bubbles
{boolean} <optional>
the event bubbles flag cancelable
{boolean} <optional>
the cancellable event flag detail
{Object} <optional>
the additional event details - Returns:
-
{boolean}
true
if event was async or not cancelled - Source:
- rapidcontext/ui/event.mjs, line 26
off(eventopt, selectoropt, listeneropt) → {Node}
Removes one or more previously attached event listeners. If no event details or listeners are specified, all matching handlers are removed.
- Parameters:
-
Name Type Attributes Description event
{string} <optional>
the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} <optional>
the event handler function (or false
) - Returns:
- {Node} the input DOM node (for chaining calls)
- Source:
- rapidcontext/ui/event.mjs, line 77
on(event, selectoropt, listener, optsopt) → {Node}
Attaches a listener function for one or more events.
- Parameters:
-
Name Type Attributes Description event
{string} the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} the event handler function (or false
)opts
{Object} <optional>
the event listener options (see addEventListener) Properties
Name Type Attributes Description delay
{number} <optional>
an inactivity delay before calling listener - Returns:
- {Node} the input DOM node (for chaining calls)
- Source:
- rapidcontext/ui/event.mjs, line 44
once(event, selectoropt, listener, optsopt) → {Node}
Attaches a single event listener function. The listener will be removed the first time an event is triggered.
- Parameters:
-
Name Type Attributes Description event
{string} the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} the event handler function (or false
)opts
{Object} <optional>
the event listener options (see addEventListener) Properties
Name Type Attributes Description delay
{number} <optional>
an inactivity delay before calling listener - Returns:
- {Node} the input DOM node (for chaining calls)
- Source:
- rapidcontext/ui/event.mjs, line 60
(static) emit(src, event, optsopt) → {boolean}
Dispatches a single event for a DOM node. Also creates a new CustomEvent instance if needed.
- Parameters:
-
Name Type Attributes Description src
{Node} the DOM node emitting the event event
{string/Event} the event type name or instance opts
{Object} <optional>
the event options Properties
Name Type Attributes Default Description async
{boolean} <optional>
true the async dispatch flag bubbles
{boolean} <optional>
the event bubbles flag cancelable
{boolean} <optional>
the cancellable event flag detail
{Object} <optional>
the additional event details - Returns:
-
{boolean}
true
if event was async or not cancelled - Source:
- rapidcontext/ui/event.mjs, line 94
(static) off(src, eventopt, selectoropt, listeneropt) → {Node}
Removes one or more previously attached event listeners. If no event details or listeners are specified, all matching handlers are removed.
- Parameters:
-
Name Type Attributes Description src
{Node} the DOM node when event handler is attached event
{string} <optional>
the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} <optional>
the event handler function (or false
) - Returns:
- {Node} the input DOM node (for chaining calls)
- Source:
- rapidcontext/ui/event.mjs, line 173
(static) on(src, event, selectoropt, listener, optsopt) → {Node}
Attaches a listener function for one or more events.
- Parameters:
-
Name Type Attributes Description src
{Node} the DOM node when event handler is attached event
{string} the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} the event handler function (or false
)opts
{Object} <optional>
the event listener options (see addEventListener) Properties
Name Type Attributes Description delay
{number} <optional>
an inactivity delay before calling listener - Returns:
- {Node} the input DOM node (for chaining calls)
- Source:
- rapidcontext/ui/event.mjs, line 119
(static) once(src, event, selectoropt, listener, optsopt) → {Node}
Attaches a single event listener function. The listener will be removed the first time an event is triggered.
- Parameters:
-
Name Type Attributes Description src
{Node} the DOM node when event handler is attached event
{string} the event type name (or space separated names) selector
{string} <optional>
the CSS selector to match for event target listener
{function} the event handler function (or false
)opts
{Object} <optional>
the event listener options (see addEventListener) Properties
Name Type Attributes Description delay
{number} <optional>
an inactivity delay before calling listener - Returns:
- {Node} the input DOM node (for chaining calls)
- Source:
- rapidcontext/ui/event.mjs, line 152