magnificent-oyster-76704
03/23/2022, 11:29 PMcareful-cpu-82706
03/23/2022, 11:55 PMcareful-cpu-82706
03/23/2022, 11:55 PMmagnificent-oyster-76704
03/24/2022, 12:00 AMmagnificent-oyster-76704
03/24/2022, 12:01 AMeager-tiger-27508
03/24/2022, 3:42 AMstocky-dentist-80693
03/24/2022, 7:51 AMmysterious-toddler-20573
03/24/2022, 12:56 PMlate-king-98305
03/24/2022, 8:23 PMrapid-umbrella-80895
03/24/2022, 8:26 PMeager-tiger-27508
03/25/2022, 12:53 PMhtml
<form hx-post="/someURL" hx-target="#section1" ...>
...
</form>
Your response HTML should look like:
html
<div id="section1">
Section1 New Content
</div>
<div id="section2" hx-swap-oob="true">
Section2 New Content
</div>
<div id="section3" hx-swap-oob="true">
Section3 New Content
</div>
The section1 div will be swapped in as if you were just returning the section1 HTML by itself. You already target section1 in the htmx request so you don't have to use hx-swap-oob for it. You just need it for the other two sections.rapid-umbrella-80895
03/25/2022, 8:21 PMhundreds-florist-41091
03/27/2022, 6:33 PMmysterious-toddler-20573
03/27/2022, 11:13 PMhx-push-url situation, but unfortunately that API isn't 100% supported yetmysterious-toddler-20573
03/27/2022, 11:14 PMlimited-farmer-86835
03/28/2022, 9:32 AMlimited-farmer-86835
03/28/2022, 9:39 AMmysterious-toddler-20573
03/28/2022, 10:40 AMlimited-farmer-86835
03/28/2022, 10:41 AMlimited-farmer-86835
03/28/2022, 10:43 AMmysterious-toddler-20573
03/28/2022, 10:45 AMlate-king-98305
03/28/2022, 4:23 PMhundreds-florist-41091
03/28/2022, 8:08 PMlate-king-98305
03/28/2022, 8:13 PMhundreds-florist-41091
03/28/2022, 8:17 PMlate-king-98305
03/28/2022, 8:35 PMhx-target, I was able to simulate a POST-redirect-GET pattern (which is what I tried to explain in the blog post; hopefully that came across).
Keep in mind that, with htmx, whatever URL you send with the 303 should contain all the content needed to refresh the "main" part of your page. Without htmx (no JS), the response from that URL should display an entire page; at that point, you're just writing a traditional request/response web application. π
Like I said, I haven't tried this without JS. The browser tools will show you what the AJAX request is, and how it eventually resolves; your server-side logs should show you the sequence of requests, so you can see if the URL you're returning with the 303 sends back enough information to render the page. (Debugging will be a bit different if you're trying to make it work with htmx or without it.)silly-soccer-20915
03/29/2022, 12:07 AMhx-swap-oob="true swap:1s" while the anchor tag triggering the swap has hx-swap="false" I also don't see the htmx-swapping/htmx-added classes added to oob elements, is this configurable somehow or default behaviour? maybe I should just move the indicator up in the tree? thanks for your help! I am enjoying htmx so so much that I try to include it on any project upon minor provocation π EDIT: just went ahead and pointed the indicator higher on the tree, works fine, solved!full-terabyte-90567
03/29/2022, 1:10 PM<div hx-trigger="load" hx-push-url="/app/test?{{ query }}"></div>full-terabyte-90567
03/29/2022, 1:19 PM<div hx-get="/app/empty" hx-trigger="load" hx-push-url="/app/test?{{ query }}"></div>hundreds-camera-24900
03/29/2022, 2:43 PM