From f7e4fc76cb914c204aa6b8c7c881eb7838956ca6 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 3 Jan 2022 15:04:23 +0100 Subject: [PATCH] Use proper events for global event handlers --- app/javascript/packs/application.ts | 2 +- app/javascript/retrospring/features/inbox/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/packs/application.ts b/app/javascript/packs/application.ts index 41a9f0fb..a52734c7 100644 --- a/app/javascript/packs/application.ts +++ b/app/javascript/packs/application.ts @@ -7,7 +7,7 @@ import initLists from 'retrospring/features/lists'; start(); document.addEventListener('turbolinks:load', initAnswerbox); -document.addEventListener('turbolinks:load', initInbox); +document.addEventListener('DOMContentLoaded', initInbox); document.addEventListener('DOMContentLoaded', initUser); document.addEventListener('turbolinks:load', initSettings); document.addEventListener('DOMContentLoaded', initLists); \ No newline at end of file diff --git a/app/javascript/retrospring/features/inbox/index.ts b/app/javascript/retrospring/features/inbox/index.ts index d5284fa9..8e6ff29d 100644 --- a/app/javascript/retrospring/features/inbox/index.ts +++ b/app/javascript/retrospring/features/inbox/index.ts @@ -6,10 +6,10 @@ import { generateQuestionHandler } from './generate'; export default (): void => { registerEvents([ - { type: 'click', target: document.querySelector('#ib-generate-question'), handler: generateQuestionHandler }, - { type: 'click', target: document.querySelector('#ib-delete-all'), handler: deleteAllQuestionsHandler }, - { type: 'click', target: document.querySelector('#ib-delete-all-author'), handler: deleteAllAuthorQuestionsHandler }, - { type: 'submit', target: document.querySelector('#author-form'), handler: authorSearchHandler } + { type: 'click', target: '#ib-generate-question', handler: generateQuestionHandler, global: true }, + { type: 'click', target: '#ib-delete-all', handler: deleteAllQuestionsHandler, global: true }, + { type: 'click', target: '#ib-delete-all-author', handler: deleteAllAuthorQuestionsHandler, global: true }, + { type: 'submit', target: '#author-form', handler: authorSearchHandler, global: true } ]); registerInboxEntryEvents();