From 5aa4fcd66f745495566faef0c1e9dc639c78a3fc Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Wed, 8 Jan 2020 10:13:58 +0100 Subject: [PATCH] Add close function for Toasts --- app/templates/base.html.j2 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index 251b6d86..3b717a8b 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -193,8 +193,13 @@ } } {% for message in get_flashed_messages() %} - M.toast({html: '{{ message }}'}) + M.toast({"classes": "rounded", "html": '{{ message }}'}); {% endfor %} + for (toastActionElement of document.querySelectorAll(".toast-action[data-action='close']")) { + toastActionElement.addEventListener("click", function(event) { + M.Toast.getInstance(toastActionElement.parentElement).dismiss(); + }); + }