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
The documentation on swapping says that for delete, hx-swap "deletes the target element regardless of the response"
While #1130 has raised the issue of this not happening for 204 response codes, i think it should go further— if hx-target and hx-swap="delete" are set, the target should be deleted even if none of hx-get, hx-post, hx-put, hx-patch, or hx-delete are set.
Current use case is loading the full size of an image and then, to remove it, deleting it entirely. Of course JavaScript can do this, but lifting this arbitrary constraint on HTMX feels like a consistent approach.
The text was updated successfully, but these errors were encountered:
Hey, while I understand the concern, imho this doesn't and shouldn't belong to htmx ; htmx's goal is to make interactions with the server, and with a pure client-side interaction like this, it would require a lot of specific if statements in the codebase to skip many parts of the usual process (no XMLHTTPRequest to make, but still fire the settling phase and events after that with the swap logic...)
You may want to look into hyperscript as this one is a pure client-side library.
Note that I would strongly advise using custom JS here, with a simple element.remove() call.
Or, if you really want some reusable thing within htmx only, make an extension of your own that sets up elements with a [hx-swap="delete"]|hx-target] selector for example, or something similar.
The documentation on swapping says that for delete, hx-swap "deletes the target element regardless of the response"
While #1130 has raised the issue of this not happening for 204 response codes, i think it should go further— if
hx-target
andhx-swap="delete"
are set, the target should be deleted even if none ofhx-get
,hx-post
,hx-put
,hx-patch
, orhx-delete
are set.Current use case is loading the full size of an image and then, to remove it, deleting it entirely. Of course JavaScript can do this, but lifting this arbitrary constraint on HTMX feels like a consistent approach.
The text was updated successfully, but these errors were encountered: