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="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 })
})
_="on submit toggle @disabled <button/> in me until htmx:afterOnLoad"
See: Cookbookhx-trigger="load, submit"
See: Handbookhtmx: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)]"
See: hx-trigger
fetch
. See: https://github.com/bigskysoftware/htmx/issues/912_="on submit halt the event action(target) trigger ready"
hx-trigger="ready"
fetch
. See: async transparency