From 9c68c4ff1c516a52bf52fe678685a00a6e284185 Mon Sep 17 00:00:00 2001 From: Ross Date: Sun, 26 Oct 2025 21:06:34 +0000 Subject: [PATCH] Add HTMX trigger to close review modal after saving --- generic/views.py | 8 ++++++-- templates/base.html | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/generic/views.py b/generic/views.py index 95746ae7..b268f1e8 100644 --- a/generic/views.py +++ b/generic/views.py @@ -2998,8 +2998,12 @@ class GenericViewBase: status=form.cleaned_data["status"], comment=form.cleaned_data.get("comment", ""), ) - - return render(request, "generic/partials/question_review_block.html", {"review": review, "question": question, "app_name": self.app_name}) + # Render the updated review block and include an HX-Trigger so the client + # can close the modal (HTMX will dispatch the event named below). + resp = render(request, "generic/partials/question_review_block.html", {"review": review, "question": question, "app_name": self.app_name}) + # Trigger a client-side event; base template will listen for this and hide the modal + resp["HX-Trigger"] = "reviewSaved" + return resp # Default: render the block (latest if exists, otherwise form) if latest: diff --git a/templates/base.html b/templates/base.html index 5e0698ec..080cf292 100644 --- a/templates/base.html +++ b/templates/base.html @@ -194,6 +194,25 @@
  • About
  • + + \ No newline at end of file