diff --git a/app/javascript/retrospring/utilities/on.ts b/app/javascript/retrospring/utilities/on.ts new file mode 100644 index 00000000..1d7d5211 --- /dev/null +++ b/app/javascript/retrospring/utilities/on.ts @@ -0,0 +1,7 @@ +export function on(type: string, selector: string, callback: Function): void { + document.addEventListener(type, (event: Event) => { + if ((event.target as HTMLElement).matches(selector)) { + callback(event); + } + }); +}; \ No newline at end of file