transition

This commit is contained in:
2024-08-14 22:04:34 +03:00
parent 1ab3f678b7
commit 1f3ebafe69
50 changed files with 924 additions and 172 deletions
+24
View File
@@ -0,0 +1,24 @@
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");
}
});
}