mysterious-toddler-20573
03/30/2021, 12:30 AMgentle-dream-18175
03/30/2021, 12:31 AMmysterious-toddler-20573
03/30/2021, 12:32 AMgentle-dream-18175
03/30/2021, 12:32 AMgentle-dream-18175
03/30/2021, 12:32 AMmysterious-toddler-20573
03/30/2021, 12:32 AMmysterious-toddler-20573
03/30/2021, 12:33 AMgentle-dream-18175
03/30/2021, 12:33 AMmysterious-toddler-20573
03/30/2021, 12:33 AMsalmon-whale-14625
03/30/2021, 12:35 AMgentle-dream-18175
03/30/2021, 12:36 AMsalmon-whale-14625
03/30/2021, 12:37 AMmysterious-toddler-20573
03/30/2021, 12:39 AMbig-rocket-55039
03/30/2021, 3:11 AMhx-* parameters and values of hx-*.salmon-whale-14625
03/30/2021, 4:16 AMtbody doesn't seem to work properly if it comes with an out of band swap. This is my response
html
<span id="btnClear" hx-swap-oob="true"><a class="btn btn-link" href="/">Clear Filters</a></span>
<tr>
<td>aaa</td>
</tr>
<tr>
<td>bbb</td>
</tr>
The tr and td tags are stripped before swappingsalmon-whale-14625
03/30/2021, 4:18 AMmodern-magician-31332
03/30/2021, 6:58 AMsalmon-whale-14625
03/30/2021, 9:07 AMsalmon-xylophone-28580
03/30/2021, 9:55 AMsalmon-xylophone-28580
03/30/2021, 10:11 AMsalmon-whale-14625
03/30/2021, 12:38 PMmysterious-toddler-20573
03/30/2021, 2:58 PMmysterious-toddler-20573
03/30/2021, 3:00 PMmysterious-toddler-20573
03/30/2021, 3:02 PMmost-jelly-15242
03/30/2021, 4:13 PMsparse-musician-64201
03/30/2021, 4:16 PMgorgeous-ghost-95789
03/30/2021, 4:20 PMgentle-dream-18175
03/30/2021, 5:08 PMgorgeous-ghost-95789
03/30/2021, 5:09 PMgorgeous-ghost-95789
03/30/2021, 5:16 PMhtml
<div id="modal">
<div class="modal-underlay" _="on click trigger closeModal"></div>
<div class="modal-content">
<h3>{{.Label}}</h3>
<form hx-post="{{.URL}}" hx-swap="beforeend">
{{ .RenderForm }}
<input type="submit" class="button primary" value="Save Changes">
<span class="button"_="on click trigger closeModal">Cancel</span>
</form>
</div>
</div>
And here's the hyperscript that handles the closeModal event:
hyperscript
on closeModal(event)
add .closing to #modal
if (not (no event.detail.nextPage))
set window.location to event.detail.nextPage
end
wait for animationend
remove #modal
end
When the user clicks on the underlay, or the "cancel" button, then the "closeModal" event is fired and the ".closing" animation begins.
If the user clicks the "submit" button then the form goes to the server, which updates the database. It responds with an empty page with a header like this: HX-Trigger:{"closeModal":{"nextPage":"/next-page-url"}} which activates the part of the hyperscript that sends the user to a new page location.