Do not serialize empty values for state and pipe
Change-Id: I641774560d2465c2a85d74d5d5b6f312861ff539
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 7be0a13..1796c6a 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -504,6 +504,18 @@
input.removeAttribute('name');
};
+ if (KorAP.States != null) {
+ const statesE = KorAP.States.element();
+ if (statesE.value == "")
+ statesE.removeAttribute('name');
+ };
+
+ if (KorAP.Pipe != null) {
+ const pipeE = KorAP.Pipe.element();
+ if (pipeE.value == "")
+ pipeE.removeAttribute("name");
+ };
+
// This would preferably set the query to be "disabled",
// but in that case the query wouldn't be submitted
// at all.
@@ -511,6 +523,13 @@
// of webkit.
qf.classList.add("loading");
d.getElementById('qsubmit').classList.add("loading");
+
+ // Alternatively the submission could be prevented early
+ // and the formData API could be used instead:
+ // e.preventDefault();
+ // const formData = new FormData(this);
+ // const queryString = new URLSearchParams(formData).toString();
+ // window.location.href = `${this.action}?${queryString}`;
});
};