mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-31 15:29:08 +01:00
Add $.on
vanilla JS substitute
This commit is contained in:
parent
89127aa313
commit
3b5e963da5
1 changed files with 7 additions and 0 deletions
7
app/javascript/retrospring/utilities/on.ts
Normal file
7
app/javascript/retrospring/utilities/on.ts
Normal file
|
@ -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);
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Reference in a new issue