You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: clarify HX-Retarget interaction with hx-swap="none" (#3446)
HX-Retarget only changes *where* the swap happens — the swap style is still
determined by the source element's hx-swap (or by HX-Reswap). When the source
uses hx-swap="none", retargeting alone produces a no-op because the "none"
swap style applies at the new target too.
Updates the HX-Retarget entries in both docs.md and reference.md to spell
this out and point users at HX-Reswap. The behavior itself is intentional
and consistent — only the docs were silent on this combination.
The original issue reporter noticed the surprise and explicitly suggested
"I would update the docs to include that setting hx-swap='none' will
prevent the use of a swap via HX-Retarget."
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: www/content/docs.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1038,7 +1038,7 @@ htmx supports some htmx-specific response headers:
1038
1038
*`HX-Refresh` - if set to "true" the client-side will do a full refresh of the page
1039
1039
*[`HX-Replace-Url`](@/headers/hx-replace-url.md) - replaces the current URL in the location bar
1040
1040
*`HX-Reswap` - allows you to specify how the response will be swapped. See [hx-swap](@/attributes/hx-swap.md) for possible values
1041
-
*`HX-Retarget` - a CSS selector that updates the target of the content update to a different element on the page
1041
+
*`HX-Retarget` - a CSS selector that updates the target of the content update to a different element on the page. Note that this only changes *where* the swap happens; the swap style is still determined by the source element's [`hx-swap`](@/attributes/hx-swap.md) (or `HX-Reswap`). If the source uses `hx-swap="none"`, you also need to send `HX-Reswap` to make the swap actually occur at the new target.
1042
1042
*`HX-Reselect` - a CSS selector that allows you to choose which part of the response is used to be swapped in. Overrides an existing [`hx-select`](@/attributes/hx-select.md) on the triggering element
1043
1043
*[`HX-Trigger`](@/headers/hx-trigger.md) - allows you to trigger client-side events
1044
1044
*[`HX-Trigger-After-Settle`](@/headers/hx-trigger.md) - allows you to trigger client-side events after the settle step
Copy file name to clipboardExpand all lines: www/content/reference.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,7 +116,7 @@ All other attributes available in htmx.
116
116
| `HX-Refresh` | if set to "true" the client-side will do a full refresh of the page
117
117
| [`HX-Replace-Url`](@/headers/hx-replace-url.md) | replaces the current URL in the location bar
118
118
| `HX-Reswap` | allows you to specify how the response will be swapped. See [hx-swap](@/attributes/hx-swap.md) for possible values
119
-
| `HX-Retarget` | a CSS selector that updates the target of the content update to a different element on the page
119
+
| `HX-Retarget` | a CSS selector that updates the target of the content update to a different element on the page (only changes *where* the swap happens; combine with `HX-Reswap` if the source has `hx-swap="none"`)
120
120
| `HX-Reselect` | a CSS selector that allows you to choose which part of the response is used to be swapped in. Overrides an existing [`hx-select`](@/attributes/hx-select.md) on the triggering element
121
121
| [`HX-Trigger`](@/headers/hx-trigger.md) | allows you to trigger client-side events
122
122
| [`HX-Trigger-After-Settle`](@/headers/hx-trigger.md) | allows you to trigger client-side events after the settle step
0 commit comments