bigskysoftware / bigskysoftware/htmx

HX-Location doesn't appear to be working

Open
#2,397 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
49.4k
Forks
1.7k
Avg merge
3d 22h
Merged PRs (30d)
30

Description

I want to give users the ability to navigate deep into a crud area of the application from the dashboard. To do this I'm utilizing HX-Location, e.g.

![2024-03-11_14-46](https://github.com/bigskysoftware/htmx/assets/14217993/c42b69eb-3871-4b58-842b-de2ab1b7af99)

I am returning some _hypermedia_ to be inserted into the specified target:

![2024-03-11_14-46_1](https://github.com/bigskysoftware/htmx/assets/14217993/a5e8e8c2-791e-4d01-a937-03cbe8c4712e)

However, while the page container matching the path is successfully loaded, the container (which is part of the base response) doesn't receive what I wanted to render into it:

![2024-03-11_14-46_2](https://github.com/bigskysoftware/htmx/assets/14217993/e98754ef-9d63-4607-871b-5866e0f41e3a)

Am I right that the way this is intended to work is:
a) HTMX receives response1, which contains the HX-Location header, as well as content1, which is temporarily held; it makes a request for the path
b) HTMX receives response2, lets it settle, and then inserts content1 into the target specified in response1's HX-Location header
?

That's what appears to be (mostly) happening here. /edit is the initial request from the dashboard; my backend detects that we're not on the path that we need to be, and so dynamically adds the HX-Location with the response; /ingredients is then requested, and renders...but then (as above) we fail to render the original response from /edit into it.

![2024-03-11_14-49](https://github.com/bigskysoftware/htmx/assets/14217993/87e36c38-c45f-4e89-914a-b5f7ec7a8cc7)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.