mysterious-toddler-20573
09/03/2021, 7:42 PMmillions-island-74338
09/03/2021, 7:43 PMmillions-island-74338
09/03/2021, 7:44 PMquiet-angle-80724
09/03/2021, 8:19 PMtrue. As I already have htmx in the project, I thought I can use it here too.mysterious-toddler-20573
09/03/2021, 8:28 PMmysterious-toddler-20573
09/03/2021, 8:28 PMsquare-elephant-35106
09/03/2021, 10:24 PMmysterious-toddler-20573
09/03/2021, 10:39 PMproud-librarian-99598
09/04/2021, 8:28 AM<button>.
This is the code I have (Based of the https://htmx.org/examples/delete-row/ example)
<ul class="todo-list" th:remove="all-but-first" hx-target="closest li" hx-swap="outerHTML swap:1s">
<li th:each="item : ${todos}" th:classappend="${item.completed()?'completed':''}">
<div class="view">
<input class="toggle" type="checkbox" th:attrappend="checked=${item.completed()?'true':null}">
<label th:text="${item.title()}">Taste JavaScript</label>
<button class="destroy" th:attr="hx-delete=${'/' + item.id}"></button>
</div>
<input class="edit" value="Create a TodoMVC template">
</li>
So I have hx-target="closest li" hx-swap="outerHTML swap:1s" on the <ul>.
And I have th:attr="hx-delete=${'/' + item.id}" on the delete button itself.
HTMX is doing a DELETE request to the server and it comes back with a 204 No Content, but the <li> is not removed from the page. Any idea what might be wrong?proud-librarian-99598
09/04/2021, 8:36 AMDELETE request needs to return an empty body, not a 204 No Content. Would it be possible to make it work if the server returns a 204 ?mysterious-toddler-20573
09/04/2021, 12:51 PMmysterious-toddler-20573
09/04/2021, 12:51 PMmysterious-toddler-20573
09/04/2021, 12:51 PMmysterious-toddler-20573
09/04/2021, 12:52 PMmysterious-toddler-20573
09/04/2021, 12:52 PMmysterious-toddler-20573
09/04/2021, 12:53 PMmysterious-toddler-20573
09/04/2021, 12:56 PMgorgeous-airport-54386
09/04/2021, 12:57 PMmysterious-toddler-20573
09/04/2021, 12:57 PMjavascript
if(htmx.config.unprocessedResponseCodes.indexOf(xhr.status)) {mysterious-toddler-20573
09/04/2021, 12:57 PMmysterious-toddler-20573
09/04/2021, 12:57 PMmysterious-toddler-20573
09/04/2021, 12:58 PMmysterious-toddler-20573
09/04/2021, 12:58 PMgorgeous-airport-54386
09/04/2021, 12:58 PMmysterious-toddler-20573
09/04/2021, 12:58 PMmysterious-toddler-20573
09/04/2021, 12:58 PMmysterious-toddler-20573
09/04/2021, 12:58 PMmysterious-toddler-20573
09/04/2021, 12:59 PMgorgeous-airport-54386
09/04/2021, 1:00 PMgorgeous-airport-54386
09/04/2021, 1:01 PM