diff --git a/front/js/htmx-form.js b/front/js/htmx-form.js deleted file mode 100644 index d0d265b..0000000 --- a/front/js/htmx-form.js +++ /dev/null @@ -1,24 +0,0 @@ -export function loadHtmxFormsBehaviour(){ - document.querySelectorAll(".form").forEach(el => { - initHtmxForm(el); - }) - -} - -function initHtmxForm(el){ - el.addEventListener("htmx:responseError", (e) => { - el.querySelector(".form-errors").innerHTML = e.detail.xhr.response; - }); - - const formEl = el.querySelector("form"); - - if(!formEl.getAttribute("hx-redirect")){ - return; - } - el.addEventListener("htmx:afterOnLoad", (e) => { - if(e.detail.successful){ - return window.location.href = formEl.getAttribute("hx-redirect"); - } - }); - -}