diff --git a/app/javascript/alchemy_admin/utils/events.js b/app/javascript/alchemy_admin/utils/events.js index 8d085ae993..933d8d5b85 100644 --- a/app/javascript/alchemy_admin/utils/events.js +++ b/app/javascript/alchemy_admin/utils/events.js @@ -1,7 +1,8 @@ export function on(eventName, baseSelector, targetSelector, callback) { document.querySelectorAll(baseSelector).forEach((baseNode) => { + const targets = Array.from(baseNode.querySelectorAll(targetSelector)) + baseNode.addEventListener(eventName, (evt) => { - const targets = Array.from(baseNode.querySelectorAll(targetSelector)) let currentNode = evt.target while (currentNode !== baseNode) {