From 6a04610be89dbbc38ef986276c4eb476d4c2e6d7 Mon Sep 17 00:00:00 2001 From: Richard Schreiber Date: Wed, 15 Jun 2022 13:22:59 +0200 Subject: [PATCH] fix and improve auto-check js --- src/pretix/static/pretixpresale/js/ui/main.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pretix/static/pretixpresale/js/ui/main.js b/src/pretix/static/pretixpresale/js/ui/main.js index 256fc7cc8..d30f68f89 100644 --- a/src/pretix/static/pretixpresale/js/ui/main.js +++ b/src/pretix/static/pretixpresale/js/ui/main.js @@ -654,9 +654,18 @@ $(function () { $("[data-checked-onchange]").each(function() { var countInput = this; $("#" + this.getAttribute("data-checked-onchange")).on("change", function() { - if (countInput.type === "checkbox") countInput.checked = true; - else if (countInput.value === 0) countInput.value = 1; - $(countInput).trigger("change") + if (countInput.type === "checkbox") { + if (countInput.checked) return; + countInput.checked = true; + } + else if (countInput.type === "number" && !countInput.valueAsNumber) { + countInput.value = "1"; + } + else { + return; + } + // in case of a change, trigger event + $(countInput).trigger("change"); }); }); });