mysterious-toddler-20573
05/17/2023, 1:05 AMmysterious-toddler-20573
05/17/2023, 1:05 AMgorgeous-airport-54386
05/17/2023, 1:06 AMgreat-cartoon-12331
05/17/2023, 1:23 AMgorgeous-airport-54386
05/17/2023, 1:23 AMrefined-waiter-90422
05/17/2023, 1:25 AMcolossal-guitar-8828
05/17/2023, 1:31 AMgreat-cartoon-12331
05/17/2023, 1:38 AMcolossal-guitar-8828
05/17/2023, 1:41 AMfew-parrot-58207
05/17/2023, 1:45 AMfew-parrot-58207
05/17/2023, 1:45 AMcolossal-guitar-8828
05/17/2023, 1:55 AMgreat-cartoon-12331
05/17/2023, 2:02 AMred-farmer-97020
05/17/2023, 2:21 AMcolossal-guitar-8828
05/17/2023, 2:37 AMhttps://cdn.discordapp.com/attachments/725789747212976259/1108221675755032646/image.png▾
colossal-guitar-8828
05/17/2023, 2:37 AMhttps://cdn.discordapp.com/attachments/725789747212976259/1108221736064909322/image.png▾
mysterious-toddler-20573
05/17/2023, 2:38 AMmysterious-toddler-20573
05/17/2023, 2:38 AMhx-post="/api"
colossal-guitar-8828
05/17/2023, 2:40 AMgreat-cartoon-12331
05/17/2023, 2:43 AMcolossal-guitar-8828
05/17/2023, 2:43 AMmammoth-family-48524
05/17/2023, 3:43 AMproud-librarian-99598
05/17/2023, 7:10 AM<div id="title-edit-form-wrapper">
<form id="title-form"
hx-put="/123/title"
hx-trigger="keyup[key=='Enter']"
hx-swap="outerHTML"
@keyup.escape="htmx.ajax('GET', '/123/title', {target: '#title-edit-form-wrapper', swap: 'outerHTML'})"
>
<input type="text" id="title" name="title" value="This is a test" autofocus>
</form>
</div>
This does a PUT request if the user presses ENTER (via the hx-trigger
), but does a GET request when the user presses ESC.microscopic-lifeguard-45888
05/17/2023, 8:27 AMmammoth-family-48524
05/17/2023, 10:23 AMmammoth-family-48524
05/17/2023, 10:44 AMmicroscopic-lifeguard-45888
05/17/2023, 10:58 AMfamous-monitor-57000
05/17/2023, 10:59 AMhx-push-url
?
For example, something like this:
<form hx-push-url="/page/{input.example.value}">
<input name="example" value="123">
<button type="submit">
</form>
So when you click the button, the URL updates to /page/123
?mammoth-family-48524
05/17/2023, 11:06 AMmysterious-toddler-20573
05/17/2023, 11:25 AMX-Push-Url
header