Home > @cascadiacollections/fluentui-compat > EventGroup > on
EventGroup.on() method
Adds an event listener to the specified target.
This method registers an event listener and tracks it for automatic cleanup. Multiple listeners can be added to the same target/event combination.
Signature:
on(target: IEventTarget, eventName: string, callback: EventListener | ((...args: any[]) => void), options?: EventListenerOptions): EventGroup;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
target |
The event target (element, window, document, etc.) | |
|
eventName |
string |
The name of the event to listen for |
|
callback |
EventListener | ((...args: any[]) => void) |
The callback function to invoke when the event fires |
|
options |
(Optional) Optional event listener options (capture, passive, once, etc.) |
Returns:
This EventGroup instance for method chaining