The purpose of this guide is to provide common practices for “Hotwire Equivalent” features in htmx.
<body hx-boost="true">
to enable a Turbo Drive-like experience. See: hx-boosthx-boost
will continue to work. See: Progressive Enhancementhx-boost="false"
is equivalent to data-turbo="false"
and used to disable boost on specific links or forms. See: Handbookhx-target="body" hx-swap="outerHTML" hx-push-url="true"
See: Handbook<form>
does not submit disabled fields. See: MDN: disabledaddEventListener("submit", (event) => {
event.target.querySelectorAll("button").forEach(node => { node.disabled = true })
})
addEventListener("htmx:afterOnLoad", (event) => {
event.target.querySelectorAll("button").forEach(node => { node.disabled = false })
})
hx-on:submit= 'event.target.querySelectorAll("button").forEach(node => { node.disabled = true })'
hx-on:htmx:afterOnLoad= 'event.target.querySelectorAll("button").forEach(node => { node.disabled = false })'
_="on submit toggle @disabled <button/> in me until htmx:afterOnLoad"
See: Cookbook<turbo-frame>
required.hx-trigger="load, submit"
See: Handbook<turbo-stream>
, no <template>
required.<turbo-frame> .. </turbo-frame>
htmx:config-request
is equivalent to turbo:before-fetch-request
See: Handbook
htmx:config-request
is the same as htmx:configRequest
See: Event Namingdocument.body.addEventListener('htmx:configRequest', (event) => {
event.detail.headers['Authorization'] = `Bearer ${token}`
})
hx-trigger="submit[action(target)]"
hx-on:click="event.preventDefault(); action(this); htmx.trigger(this, 'ready')"
hx-trigger="ready"
_="on submit halt the event action(target) trigger ready"
hx-trigger="ready"
fetch
. See: async transparency