Component.registerDomEvent method
Component › registerDomEvent
Official
Registers a DOM event to be detached when unloading.Signature:
registerDomEvent(el: Window, type: K, callback: (this: HTMLElement, ev: WindowEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions | undefined): voidParameters:
| Parameter | Type | Description |
|---|---|---|
| el | Window | The element to register the event on. |
| type | K | The type of the event to register. |
| callback | (this: HTMLElement, ev: WindowEventMap[K]) => unknown | The callback to be called when the event is triggered. |
| options? | boolean | AddEventListenerOptions | undefined | The options for the event. |
Returns: void
Example:
component.registerDomEvent(window, 'click', () => { console.log('Window clicked');});Official
Registers a DOM event to be detached when unloadingSignature:
registerDomEvent(el: Document, type: K, callback: (this: HTMLElement, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): voidParameters:
| Parameter | Type | Description |
|---|---|---|
| el | Document | |
| type | K | |
| callback | (this: HTMLElement, ev: DocumentEventMap[K]) => any | |
| options? | boolean | AddEventListenerOptions | undefined | *(Optional)* |
Returns: void
Since: 0.14.8
Official
Registers a DOM event to be detached when unloadingSignature:
registerDomEvent(el: HTMLElement, type: K, callback: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): voidParameters:
| Parameter | Type | Description |
|---|---|---|
| el | HTMLElement | |
| type | K | |
| callback | (this: HTMLElement, ev: HTMLElementEventMap[K]) => any | |
| options? | boolean | AddEventListenerOptions | undefined | *(Optional)* |
Returns: void
Since: 0.14.8