billions-microphone-84331
10/05/2021, 5:09 PMbillions-microphone-84331
10/05/2021, 5:23 PM/whoami):
<!DOCTYPE html>
<html lang="en">
<head>...</head>
<body hx-boost="true">
<p>{{ "Who are you?" | translate }}</p>
<ul>
{{ range .Guests }}
<li><a hx-post="/whoami/{{ .ID }}">{{ .Name }}</a></li>
{{ end }}
</ul>
</body>
</html>
And so the user should click one of the guests in the list, which triggers a POST request. On the server, I handle this POST request by just adding a cookie/session to register the user, and then I want to redirect him to the homepage / to arrive on the list of upcoming events. But I would like this to happen without a full reload (see that I am using hx-boost on the body).
On a click in the list of guests, and instead of redirecting the user to the homepage, I could render home and implement a swap of the response into the body with htmx. But first the URL would stay /whoami and that’s not ideal. And second, this means I need to call the rendering of the homepage from the "whoami" handler on the server, and I feel it would be simpler for me to just redirect the user, and let the homepage handler do the rest.
Does the context make sense?mysterious-toddler-20573
10/05/2021, 5:46 PMmysterious-toddler-20573
10/05/2021, 5:47 PMmysterious-toddler-20573
10/05/2021, 5:49 PMmysterious-toddler-20573
10/05/2021, 5:50 PMmysterious-toddler-20573
10/05/2021, 5:50 PMHX-Push header to push / into the nav bar: https://htmx.org/reference/#response_headersmysterious-toddler-20573
10/05/2021, 5:51 PMhref on itmysterious-toddler-20573
10/05/2021, 5:51 PMbillions-microphone-84331
10/05/2021, 7:00 PMhx-boost isn’t used in that scenario effectively. That’s because I also have a navbar with regular anchors which I haven’t included here.
Maybe one more question, when I use the 302 on a htmx request (as you suggested before), where in the htmx.js code does htmx understands that it should reissue a request to the new Location before swapping?mysterious-toddler-20573
10/05/2021, 7:00 PMmysterious-toddler-20573
10/05/2021, 7:01 PMmysterious-toddler-20573
10/05/2021, 7:01 PMmysterious-toddler-20573
10/05/2021, 7:01 PMbillions-microphone-84331
10/05/2021, 7:01 PMmysterious-toddler-20573
10/05/2021, 7:01 PMmysterious-toddler-20573
10/05/2021, 7:01 PMmysterious-toddler-20573
10/05/2021, 7:02 PMbillions-microphone-84331
10/05/2021, 7:02 PMmysterious-toddler-20573
10/05/2021, 7:02 PMbillions-microphone-84331
10/05/2021, 7:08 PMHX-Redirect in response to a request that has been fired from an element which is in a hx-boost scope?
Don’t know if you have access to the element from which the request has been fired at that moment, but maybe by checking that this element is inside a hx-boost parent, htmx could decide to reissue a boosted request to the location instead of simply window.location.href?
Maybe it does not feel right in the design and it is a little too specific? (just trying to get a full picture of the limitations here ^^)adamant-exabyte-92636
10/05/2021, 7:17 PMadamant-exabyte-92636
10/05/2021, 7:18 PMbillions-microphone-84331
10/05/2021, 7:19 PMhx-boost = "true" scenario from my navbar. If i have something like :
<body hx-boost="true">
<nav>
<div>
<a href="/">home</a>
<a href="/one">one</a>
<a href="/two">two</a>
<a href="/redir">redirect 302 to home</a>
</div>
</nav>
<main>content of home</main>
</body>
When I browse the home, one or two, I have normal boosted requests (intercepted by htmx). When I click /redir (which behind the scenes only respond a 302 Location to home), a new xhr request is fired (probably by the browser as you said), but it seems HX-Boosted is sent in that new request. How is that possible if this is handled by the browser and not by htmx directly?mysterious-toddler-20573
10/05/2021, 7:38 PMbillions-microphone-84331
10/05/2021, 7:49 PMHX-Boosted.important-winter-64905
10/05/2021, 8:36 PMtd element to flash similar to https://htmx.org/examples/bulk-update/
using
.htmx-settling td.update_flash {
background: darkseagreen;
}
td {
transition: all 1.2s;
}important-winter-64905
10/05/2021, 8:38 PMupdate_flash class into the class which seems to work but there is no flash of green as expectedimportant-winter-64905
10/05/2021, 8:47 PM<td class="" id="abc_this" nowrap="nowrap">
<input hx-target="#abc_this" hx-swap="outerHTML swap:1s"
class="form-control form-control-sm" type="number"
name="nameabc" value="0.00" step="0.5"
hx-post="/projects/update" hx-trigger="change delay:0.1s">
</td>billions-microphone-84331
10/05/2021, 8:48 PM