mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-12-01 12:44:15 +01:00
feat: improve multiple toasts on the same page from different sources
This commit is contained in:
1 parent
1f4a66560a
commit
73678aacab
3 files changed
+28
-24
No files matched your search
+7
-4
@@ -7,12 +7,15 @@ function initiateToasts() {
|
||||
const toastList = [...toastElList].map(toastEl => new bootstrap.Toast(toastEl)); // eslint-disable-line no-undef
|
||||
|
||||
for (let i = 0; i < toastList.length; i++) {
|
||||
toastList[i].show();
|
||||
toastList[i]._element.addEventListener('hidden.bs.toast', (event) => {
|
||||
event.target.remove();
|
||||
});
|
||||
if (toastList[i].isShown() === false) {
|
||||
toastList[i].show();
|
||||
toastList[i]._element.addEventListener('hidden.bs.toast', (event) => {
|
||||
event.target.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', initiateToasts, false);
|
||||
document.addEventListener('htmx:afterSwap', initiateToasts, false);
|
||||
initiateToasts();
|
||||
Reference in new issue
Block a user