diff --git a/src/lib/input-change-events.js b/src/lib/input-change-events.js index 09a99c733..f7ebecb2c 100644 --- a/src/lib/input-change-events.js +++ b/src/lib/input-change-events.js @@ -38,11 +38,21 @@ const _ = { // We've been given an element that is not a form input. We // therefore assume that it's a container of form inputs and // register handlers for its children. - $el.findInclusive(":input").each(_.registerHandlersForElement); + for (const _el of $el[0].closest("form").elements) { + // Search for all form elements, also those outside the form + // container. + _.registerHandlersForElement.bind(_el)(); + } } }, registerHandlersForElement() { + let el_within_form = true; + const $form = $(this.form); + if (this.closest("form") !== this.form) { + el_within_form = false; + } + const $el = $(this); const isNumber = $el.is("input[type=number]"); const isText = $el.is("input:text, input[type=search], textarea"); @@ -53,24 +63,24 @@ const _ = { if ("onkeyup" in window) { $el.on("keyup." + namespace, function () { log.debug("translating keyup"); - $el.trigger("input-change"); + (el_within_form ? $el : $form).trigger("input-change"); }); } } if (isText || isNumber) { $el.on("input." + namespace, function () { log.debug("translating input"); - $el.trigger("input-change"); + (el_within_form ? $el : $form).trigger("input-change"); }); } else { $el.on("change." + namespace, function () { log.debug("translating change"); - $el.trigger("input-change"); + (el_within_form ? $el : $form).trigger("input-change"); }); } $el.on("blur", function () { - $el.trigger("input-defocus"); + (el_within_form ? $el : $form).trigger("input-defocus"); }); },