JS tweaks for showing messages (#60)

This commit is contained in:
2026-07-17 21:19:32 -04:00
parent 76f0506de7
commit abfae6786d
+6 -6
View File
@@ -413,6 +413,7 @@ this.Admin = {
toast.setAttribute("role", "alert")
toast.setAttribute("aria-live", "assertive")
toast.setAttribute("aria-atomic", "true")
toast.setAttribute("data-mwl-shown", "true")
toast.appendChild(toastHead)
toast.appendChild(toastBody)
@@ -430,15 +431,14 @@ this.Admin = {
* Initialize any toasts that were pre-rendered from the server
*/
showPreRenderedMessages() {
[...document.querySelectorAll(".toast")].forEach(el => {
if (el.getAttribute("data-mwl-shown") !== "true") {
[...document.querySelectorAll(".toast")]
.filter(el => !el.hasAttribute("data-mwl-shown"))
.forEach(el => {
const toast = new bootstrap.Toast(el,
el.getAttribute("data-bs-autohide") === "false"
? { autohide: false } : { delay: 6000, autohide: true })
el.getAttribute("data-bs-autohide") === "false" ? { autohide: false } : { delay: 6000, autohide: true })
toast.show()
el.setAttribute("data-mwl-shown", "true")
}
})
})
}
}