diff --git a/cards/templates/cards/_backgrounds_list.html b/cards/templates/cards/_backgrounds_list.html index 62b0d20..d4690b1 100644 --- a/cards/templates/cards/_backgrounds_list.html +++ b/cards/templates/cards/_backgrounds_list.html @@ -1,7 +1,7 @@
{% for bg in backgrounds %} -
+
@@ -13,7 +13,7 @@ {% else %} Active {% endif %} - +
diff --git a/cards/templates/cards/_card_item.html b/cards/templates/cards/_card_item.html index 5726ac1..e87c476 100644 --- a/cards/templates/cards/_card_item.html +++ b/cards/templates/cards/_card_item.html @@ -52,7 +52,7 @@
- +
diff --git a/cards/views.py b/cards/views.py index 2e1bae7..bc82dbc 100644 --- a/cards/views.py +++ b/cards/views.py @@ -140,7 +140,10 @@ def card_delete(request, pk): if request.method == 'POST': card.delete() if is_htmx(request): - return HttpResponse(status=204) + # Return an empty 200 response so HTMX can replace the + # targeted element (e.g. via `hx-swap="outerHTML"`) and + # remove it from the DOM immediately. + return HttpResponse('') return redirect('cards:list') return HttpResponseBadRequest('Only POST allowed') @@ -197,7 +200,9 @@ def background_delete(request, pk): bg = get_object_or_404(BackgroundImage, pk=pk) bg.delete() if is_htmx(request): - return HttpResponse(status=204) + # See comment in `card_delete`: return empty body so HTMX can + # remove the corresponding element via `hx-swap="outerHTML"`. + return HttpResponse('') return redirect('cards:backgrounds') diff --git a/db.sqlite3 b/db.sqlite3 index 8cecf62..4a0b5bb 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ