cleanup
This commit is contained in:
@@ -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");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user