billions-microphone-84331
09/20/2021, 11:29 AM<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>myapp</title>
<script src="https://unpkg.com/htmx.org" defer></script>
<link rel="icon" href="data:,">
</head>
<body hx-boost="true">
<nav>
<div>
<a href="/">Home</a>
<a href="/guests">Guests</a>
<a href="/status">Statuses</a>
</div>
</nav>
<div id="flash" hx-swap-oob="true"></div>
<main>
<ul>
<li>test</li>
</ul>
</main>
</body>
</html>
(hx-swap-oob already exists in the original document because I use the same template for doc and htmx responses for the flash div).
And when I click on the /guests anchor, a boosted request is fired and I have this in response from the server:
<nav>
<div>
<a href="/">Home</a>
<a href="/guests">Guests</a>
<a href="/status">Statuses</a>
</div>
</nav>
<div id="flash" hx-swap-oob="true"></div>
<main>
<p>List of guests</p>
</main>
And so it swapped into the body, but the #flash div is removed from the dom :/mysterious-toddler-20573
09/20/2021, 11:34 AMmysterious-toddler-20573
09/20/2021, 11:35 AMhx-swap-oob is going to replace the content. Is there a way to test if there is a current flash to show?mysterious-toddler-20573
09/20/2021, 11:35 AMbillions-microphone-84331
09/20/2021, 11:45 AM<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>myapp</title>
<script src="https://unpkg.com/htmx.org" defer></script>
<link rel="icon" href="data:,">
</head>
<body>
<nav>
<div>
<a href="/">Home</a>
<a href="/guests">Guests</a>
<a href="/status">Statuses</a>
</div>
</nav>
<div id="flash" hx-swap-oob="true"></div>
<main>
<p>List of statuses</p>
<ul>
<li>
<span hx-get="/test" hx-target="main">test</span>
</li>
</ul>
</main>
</body>
</html>
And I click the span which makes an htmx request to /test and returns:
<div id="flash" hx-swap-oob="true"></div>
<p>my test</p>
Then, the #flash div is replaced correctly (but stays empty as the out of band #flash from the response is also empty.
Why would it be different for boosted requests?billions-microphone-84331
09/20/2021, 11:48 AMhx-boost, the target is by default the body, and so the out of band #flash div is in fact part of the target, and not outside of it. I was expecting that an out-of-band element in a response would still be replaced even if landing inside of the target.billions-microphone-84331
09/20/2021, 11:49 AM#main and so #flash is outside (aka out-of-band) of #main).billions-microphone-84331
09/20/2021, 11:51 AMhx-swap-oob="true" when responding with the #flash div.billions-microphone-84331
09/20/2021, 2:01 PMHx-Boosted sent by htmx that would be different from Hx-Request. It would clearly differentiate the two use-cases ๐mysterious-toddler-20573
09/20/2021, 3:12 PMbillions-microphone-84331
09/20/2021, 3:47 PMhallowed-insurance-17001
09/20/2021, 3:54 PMhx-boost, but when they submit successfully and then redirect, they load the content from the new Location but they don't change the current URL in the browser. I've tried setting the HX-Push header and it doesn't have an effect. Is this expected behavior?mysterious-toddler-20573
09/20/2021, 4:32 PMmysterious-toddler-20573
09/20/2021, 8:22 PMhx-push-url='true' to the form?billions-microphone-84331
09/20/2021, 10:32 PMhallowed-insurance-17001
09/20/2021, 10:39 PM<body hx-boost="true"> with a <form> inside it. (Should this be changing the URL on redirect?)
It might be a bit until I can post more details.mysterious-toddler-20573
09/20/2021, 10:46 PMmost-flag-2080
09/20/2021, 10:53 PMbillions-microphone-84331
09/21/2021, 9:53 AMable-zebra-49180
09/21/2021, 10:17 AMmysterious-toddler-20573
09/21/2021, 1:18 PMmysterious-toddler-20573
09/21/2021, 1:21 PMmysterious-toddler-20573
09/21/2021, 1:22 PMmysterious-toddler-20573
09/21/2021, 1:22 PMmysterious-toddler-20573
09/21/2021, 1:28 PMfast-nest-2846
09/21/2021, 1:35 PMuser
09/21/2021, 3:43 PMmysterious-toddler-20573
09/21/2021, 4:13 PMmost-jelly-15242
09/21/2021, 5:59 PMAccess-Control-Expose-Headers: HX-Triggermysterious-toddler-20573
09/21/2021, 9:43 PM