Skip to content

Commit 5aa07c3

Browse files
committed
BaseController - add convenience method for dispatching events
1 parent af03278 commit 5aa07c3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/base_controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export class BaseController extends Controller {
2727
});
2828
}
2929

30+
dispatch(element: HTMLElement, eventName: string, options: CustomEventInit = {bubbles: true, cancelable: true, detail: {target: element}}) {
31+
let event = new CustomEvent(eventName, options);
32+
element.dispatchEvent(event);
33+
}
34+
3035
log(functionName: string, args: {} = {}): void {
3136
// @ts-ignore
3237
if (!this.application.debug) {

0 commit comments

Comments
 (0)