From 367fe0e7a62e3371c2a31abea540c030858d3864 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 3 Jan 2022 05:15:01 +0100 Subject: [PATCH] Use `registerEvents` to register multiple global events --- app/javascript/retrospring/features/lists/index.ts | 12 +++++++----- app/javascript/retrospring/features/user/index.ts | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/javascript/retrospring/features/lists/index.ts b/app/javascript/retrospring/features/lists/index.ts index 4bb9d71f..4bfc9319 100644 --- a/app/javascript/retrospring/features/lists/index.ts +++ b/app/javascript/retrospring/features/lists/index.ts @@ -1,11 +1,13 @@ -import { on } from 'retrospring/utilities/on'; +import registerEvents from 'retrospring/utilities/registerEvents'; import { createListHandler, createListInputHandler } from './create'; import { destroyListHandler } from './destroy'; import { listMembershipHandler } from './membership'; export default (): void => { - on('click', 'input[type=checkbox][name=gm-list-check]', listMembershipHandler); - on('click', 'button#create-list', createListHandler); - on('click', 'a#delete-list', destroyListHandler); - on('keyup', 'input#new-list-name', createListInputHandler); + registerEvents([ + { type: 'click', target: 'input[type=checkbox][name=gm-list-check]', handler: listMembershipHandler, global: true }, + { type: 'click', target: 'button#create-list', handler: createListHandler, global: true }, + { type: 'click', target: 'a#delete-list', handler: destroyListHandler, global: true }, + { type: 'click', target: 'input#new-list-name', handler: createListInputHandler, global: true }, + ]); } \ No newline at end of file diff --git a/app/javascript/retrospring/features/user/index.ts b/app/javascript/retrospring/features/user/index.ts index c1a6bf9c..26894e3c 100644 --- a/app/javascript/retrospring/features/user/index.ts +++ b/app/javascript/retrospring/features/user/index.ts @@ -1,8 +1,10 @@ import { userActionHandler } from './action'; import { userReportHandler } from './report'; -import { on } from 'utilities/on'; +import registerEvents from 'retrospring/utilities/registerEvents'; export default (): void => { - on('click', 'button[name=user-action]', userActionHandler); - on('click', 'a[data-action=report-user]', userReportHandler); + registerEvents([ + { type: 'click', target: 'button[name=user-action]', handler: userActionHandler, global: true }, + { type: 'click', target: 'a[data-action=report-user]', handler: userReportHandler, global: true } + ]); } \ No newline at end of file