ancient-father-3063
09/04/2022, 8:29 AMbland-coat-6833
09/04/2022, 9:01 AMancient-father-3063
09/04/2022, 9:04 AMancient-father-3063
09/04/2022, 9:15 AMancient-father-3063
09/04/2022, 9:16 AMmammoth-family-48524
09/04/2022, 10:06 AMbland-coat-6833
09/04/2022, 10:06 AMancient-father-3063
09/04/2022, 10:08 AMancient-father-3063
09/04/2022, 10:08 AMmammoth-family-48524
09/04/2022, 10:08 AMmammoth-family-48524
09/04/2022, 10:11 AMancient-father-3063
09/04/2022, 10:11 AMmammoth-family-48524
09/04/2022, 10:16 AMmammoth-family-48524
09/04/2022, 10:31 AMblue-ghost-19146
09/04/2022, 10:40 AMblue-ghost-19146
09/04/2022, 10:46 AMancient-father-3063
09/04/2022, 11:00 AMancient-father-3063
09/04/2022, 11:00 AMmammoth-family-48524
09/04/2022, 11:03 AMquiet-hydrogen-55425
09/04/2022, 11:03 AMmammoth-family-48524
09/04/2022, 11:08 AMmammoth-family-48524
09/04/2022, 11:17 AM<form hx-post="/your/url" hx-swap="outerHTML" hx-target="#maybe-you-want-to-specify-a-target-too">
, include a <button type="submit">
in the form, and it'll just work. HTMX will automatically include all the standard HTML form elements in the POST request sent to the server. I like to swap all my form fields in a <form>
element for this reason - it seems nice πmammoth-family-48524
09/04/2022, 11:22 AMancient-father-3063
09/04/2022, 11:28 AMancient-father-3063
09/04/2022, 11:28 AMhtml
<!-- this is the html that htmx is going to put in the target -->
<div>
<h1>Hello World</h1>
<h2 id="somewhereelse" hx-swap-oob="true">This message will not go with the h1 text, rather it will be put in the div with the id somewhereelse</h2>
</div>
ancient-father-3063
09/04/2022, 11:28 AMancient-father-3063
09/04/2022, 11:28 AMmammoth-family-48524
09/04/2022, 11:30 AM<!-- this is the html that htmx is going to put in the target -->
<div>
<h1>Hello World</h1>
</div>
<h2 id="somewhereelse" hx-swap-oob="true">This message will not go with the h1 text, rather it will be put in the div with the id somewhereelse</h2>
ancient-father-3063
09/04/2022, 11:30 AMancient-father-3063
09/04/2022, 11:30 AM