make web submit when action done by user

This commit is contained in:
Robin Olsen
2026-03-19 21:12:28 +01:00
parent ef649c9ac4
commit 35114a3e0f
9 changed files with 52 additions and 17 deletions

View File

@@ -30,11 +30,15 @@ func HandleTaskStatus(w http.ResponseWriter, r *http.Request) {
hx := HTMX(r)
if hx.IsHxRequest() {
hx.WriteString(`
if taskFeedback.Success {
w.Header().Set("HX-Trigger", "task-status-success")
w.WriteHeader(http.StatusOK)
} else {
hx.WriteString(`
<div id="status" type="button" hx-get="/status" hx-target="#status" hx-swap="outerHTML">
<button class="btn btn-error btn-sm" hx-get="/status/modal" hx-target="#modal-container" hx-swap="innerHTML">` + taskFeedback.Message + `</button>
</div>`)
}
return
}