From 78855c919aa825c5fff2c99cd137cb2eee6878a4 Mon Sep 17 00:00:00 2001 From: tdro Date: Fri, 2 Feb 2024 20:10:06 -0500 Subject: static/js/forms: Scope to inside forms Persist pageshow --- static/js/forms.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'static') diff --git a/static/js/forms.ts b/static/js/forms.ts index 2916536..24c3d09 100644 --- a/static/js/forms.ts +++ b/static/js/forms.ts @@ -8,11 +8,11 @@ return console.warn("WARNING: Cannot persist form state due to cookie restrictions"); } - ["URLChangedCustomEvent", "DOMContentLoaded"].forEach(function (event) { + ["pageshow", "URLChangedCustomEvent", "DOMContentLoaded"].forEach(function (event) { self.addEventListener(event, function (event) { - const input = Array.prototype.slice.call(document.querySelectorAll("input")); - const select = Array.prototype.slice.call(document.querySelectorAll("select")); - const textarea = Array.prototype.slice.call(document.querySelectorAll("textarea")); + const input = Array.prototype.slice.call(document.querySelectorAll("form input")); + const select = Array.prototype.slice.call(document.querySelectorAll("form select")); + const textarea = Array.prototype.slice.call(document.querySelectorAll("form textarea")); const states = input.concat(select).concat(textarea); @@ -27,7 +27,7 @@ states[i].addEventListener("change", function (event) { - // console.log("INFO: STATE", event.target); + // console.log("INFO: STATE:", event.target); // console.log("INFO: ID:", event.target.id); // console.log("INFO: NAME:", event.target.name); // console.log("INFO: TYPE:", event.target.type); -- cgit v1.2.3