One thing that I'm missing with HTMX and Django is proper error handling.
By default HTMX swallows any response that is not a 2xx, which might leave your users hanging on an endless loading state.
Does anyone have a good solution for this that can be reused between projects?
@anze3db I’m not sure there’s a better way than what you’re doing right now that doesn’t involve listening for the responseError event and writing client-side JS. They could add hx-error-swap / hx-error-target, for example, to implement this. Might be worth suggesting. (1/2)
Also, not immediately relevant to your current issue but something that might be worth considering for the future: using the htmx websocket extension, you can basically implement a streaming HTML approach (example using Kitten: https://ar.al/2024/03/08/streaming-html/) where you can just stream errors to the page as they happen.
#htmx #webSocket #Kitten #SmallWeb #StreamingHTML #errorHandling (2/2)
@aral Benjamin pointed out that there is an extension that allows you to define hx-target-error: https://social.data.coop/@benjaoming/112439119762935983
@anze3db Ah nice :)