You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's acceptable for trivial cases, but gets very messy and hard to maintain when more branching logic is required.
These are the related events, but they are for the "error" or "error-or-success" cases:
htmx:afterOnLoad This event is triggered after an AJAX onload has finished. Note that this does not mean that the content has been swapped or settled yet, only that the request has finished.
htmx:afterRequest This event is triggered after an AJAX request has finished either in the case of a successful request (although one that may have returned a remote error code such as a 404) or in a network error situation.
htmx:responseError This event is triggered when an HTTP error response occurs
SOLUTION
It would be cleaner to have a "success case" event, e.g. htmx:responseSuccess.
That would be simpler and we could use different handlers for different responses, instead of one mega handler with ugly branching logic (or worse, doing it in a script file).
The text was updated successfully, but these errors were encountered:
PROBLEM
If an error occurs during an ajax request, we can use
htmx:responseError
to handle it:But there isn't a corresponding event for a success case. One could use this workaround:
That's acceptable for trivial cases, but gets very messy and hard to maintain when more branching logic is required.
These are the related events, but they are for the "error" or "error-or-success" cases:
SOLUTION
It would be cleaner to have a "success case" event, e.g.
htmx:responseSuccess
.That would be simpler and we could use different handlers for different responses, instead of one mega handler with ugly branching logic (or worse, doing it in a script file).
The text was updated successfully, but these errors were encountered: