adamant-state-54102
04/11/2022, 2:38 PMmysterious-toddler-20573
04/11/2022, 2:41 PMmysterious-toddler-20573
04/11/2022, 2:42 PMadamant-state-54102
04/11/2022, 2:44 PMpowerful-eye-47205
04/11/2022, 3:52 PMhx-boost behavior from the server-side? I'd like to serve the "form w/errors" partial by default and redirect to the "items list" page on success -- but I don't want to do a full refresh -- I want to stay in happy hx-boosted-land. πgentle-notebook-11755
04/11/2022, 7:25 PM<body _="on htmx:beforeRequest
add .main--hidden to .main
wait 150ms
then settle then go to the top of the body instantly
end">
There a few other things but the htmx:beforeRequest is the key part.
Now, I have another element in my project, that needs to have its own logic for the beforeRequest. So the question is how to ignore the one defined in the body tag? If I define a new one like this:
<form _="on htmx:beforeRequest ...etc.">
would it take precedence over the one defined on the body? Or should i do it differently? Thank you so much!mysterious-toddler-20573
04/11/2022, 8:28 PMhalt in that event handler to prevent bubbling, which will prevent that event from hitting the handler on the body: https://hyperscript.org/commands/halt/gentle-notebook-11755
04/11/2022, 9:24 PMhalt command! I'll give it a try now.few-vegetable-15970
04/12/2022, 2:35 AMmysterious-toddler-20573
04/12/2022, 2:52 AMmysterious-toddler-20573
04/12/2022, 2:53 AMmysterious-toddler-20573
04/12/2022, 2:53 AMgorgeous-ghost-95789
04/12/2022, 4:51 AMfew-vegetable-15970
04/12/2022, 1:20 PMmysterious-toddler-20573
04/12/2022, 2:55 PMfew-vegetable-15970
04/12/2022, 3:18 PMlate-king-98305
04/12/2022, 5:50 PMpowerful-eye-47205
04/12/2022, 6:01 PMHX-Boost: true β it's such a killer feature. Seems a shame not to be able to invoke from the server.late-king-98305
04/12/2022, 6:03 PMpowerful-eye-47205
04/12/2022, 6:11 PMhx-boost, you DO receive a full page but then extract only the body chunk of the DOM to swap in. Maybe I'm missing something.late-king-98305
04/12/2022, 6:21 PMXMLHTTPRequest); since it's then technically a dynamic interaction on the page, the page itself doesn't change. Without htmx, the browser initiates the navigation by requesting the URL from the remote server. As far as the response, you're correct that htmx will swap in the body to the target element in the existing page. This could be a completely full page's worth of content swap, but it doesn't have to be.
Take the inline edit example on their site - the request to edit returns a form that replaces the list item entry, and once the item is submitted, the text to display that item entry is returned. When you have control over the server side, you can send different responses at the same endpoints, based on whether the request is from htmx or not; that's what I do for my "page" templates (one is full page, one is just title and body).powerful-eye-47205
04/12/2022, 6:26 PMswift-waiter-73201
04/13/2022, 11:11 AMmysterious-toddler-20573
04/13/2022, 1:02 PMmysterious-toddler-20573
04/13/2022, 2:20 PMmysterious-toddler-20573
04/13/2022, 2:20 PMearly-australia-38728
04/13/2022, 7:54 PMouterHTML:#view-xyz, beforeend:#clist that would replace #view-xyz, but if that doesn't exist, append to #clist, etc?early-australia-38728
04/13/2022, 7:56 PMeager-tiger-27508
04/14/2022, 2:39 AMeager-tiger-27508
04/14/2022, 2:40 AM