feat: add htmx error toast on error class swap

This commit is contained in:
2026-06-06 16:53:56 +02:00
parent 470e5b092b
commit 651db05cd0

View File

@@ -54,6 +54,14 @@ onReady(() => {
toast("Something went wrong");
});
document.addEventListener("htmx:afterSwap", (event) => {
const detail = event as CustomEvent<{ target?: EventTarget | null }>;
const target = detail.detail?.target;
if (!(target instanceof HTMLElement)) return;
if (!target.classList.contains("error")) return;
toast("Failed to load content");
});
document.addEventListener("htmx:sendError", () => {
toast("Network error");
});