Include note about 204 in hx-delete docs and examples #1475
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This issue has come up in the Discord a few times, as well as on GitHub: #1130
In part because Mozilla suggets a
204 - NO CONTENT
status code as an idiomatic response to theDELETE
HTTP method, a lot of people come to HTMX (myself included) expecting that returning a204
will remove the element that sent the delete request from the DOM.The reason HTMX does not do this is because of an HTMX-wide policy that the
204
response essentially means "do not swap", which is perfectly reasonable once you get to know how the library works. It's also, however, a recurring stumbling block for new users.I think this can be easily rectified by linking people to the appropriate part of the documentation from the relevant delete pages—since it is reasonably likely they will find the
hx-delete
or delete row examples before digging into the mildly more obscure section about response codes. It also highlights the increased relevance of status codes in HTMX design patterns, relative to JSON-based patterns.