From 64551bb2b73838fd821369ddf7c9e81f51db6b4d Mon Sep 17 00:00:00 2001 From: NReib <120319811+NReib@users.noreply.github.com> Date: Fri, 5 Sep 2025 14:02:03 +0200 Subject: [PATCH] [Issue #32] Add button as submitter outside of submit event Currently if an fx-action is added to a button within a form, the form is not recognized as the form's submitter and will not be included in the formdata. This checks if the triggering element is a valid submitter and includes it into the formdata if so. --- fixi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixi.js b/fixi.js index fd70c45..0180200 100644 --- a/fixi.js +++ b/fixi.js @@ -10,7 +10,7 @@ elt.__fixi = async(evt)=>{ let reqs = elt.__fixi.requests ||= new Set() let form = elt.form || elt.closest("form") - let body = new FormData(form ?? undefined, evt.submitter) + let body = new FormData(form ?? undefined, evt.submitter ?? (form && form === elt.form && elt?.matches('input,button') && elt.type === "submit" ? elt : undefined)) if (!form && elt.name) body.append(elt.name, elt.value) let ac = new AbortController() let cfg = {