bigskysoftware / bigskysoftware/htmx
When the response contains "HX-Location" any disabled elements marked by hx-disabled-elt are briefly enabled during client-side redirect.
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
Given the following htmx request made by clicking button with `type="submit"` and triggering submission of form with `hx-post`:
```
```
and the following django function-based view that `"{% url 'form_url' %}"` resolves to:
```
def post(self, request)
# Redirect client-side to next page
response = HttpResponse(status=204)
response["HX-Location"] = json.dumps({
"path": reverse("app:some_redirect_url"),
"target": "#some_target",
})
return response
```
The `hx-disabled-elt` only works properly while the 204 is pending. When the 204 is returned and the client-redirect / 200 from `HX-Location` begins pending, the page content hasn't changed at this point but the `hx-disabled-elt` stops working on the example element (`#form-id button[type='submit']`) that is still on the page. The `hx-indicator` attribute continues to work as intended.
Essentially, the targeted elements are disabled for a bit, then enabled, then finally the page content changes. This is especially noticeable on a slower/throttled network. I'm looking for the elements to be disabled all the way up until the page content (and said elements) are changed/replaced if `HX-Location` is included in the response header.
Contributor guide
Assessment
This issue has not been assessed yet.