https://htmx.org logo
To add my two pence, I use a Javascript library ca...
# 🔥-django-htmx
b
To add my two pence, I use a Javascript library called SweetAlert2 (https://sweetalert2.github.io/) to do toast notifications and have those triggered on events sent by htmx. I originally did it with an empty div but wasn't too keen on it when sending multiple events in 1 page load (e.g. list of items and users clicked several buttons) as you either can't do multiple notifications if you're replacing your placeholder div, or you have to constantly append to it. It also restricts you on ONLY being able to show toasts/alerts when your server tells you to. A big thing I wanted to do was have the page load and then if the user loses internet connection and they click on an ajax'd button have a toast notification saying "something went wrong, check connection and retry later". Making the notifications triggered via JS is simpler because I can send a header back with a level (for colour) and message and there's a handler to display it, and if I have a htmx:timeout,senderror,sendabort I can also trigger a generic toast error