summaryrefslogtreecommitdiffstatshomepage
path: root/www/content/attributes
diff options
context:
space:
mode:
authorBlake Williams <blakewilliams@github.com>2023-08-15 17:29:22 -0400
committerGitHub <noreply@github.com>2023-08-15 17:29:22 -0400
commit9ed1275ec353c0c783044799e9393c5390d66f03 (patch)
tree856f50fc87fa68805042a2b0d76940d940b81cd1 /www/content/attributes
parent47af93bdb0c9f5d356e36fd6073e0b74d12b9242 (diff)
downloadhtmx-9ed1275ec353c0c783044799e9393c5390d66f03.tar.gz
htmx-9ed1275ec353c0c783044799e9393c5390d66f03.zip
Document hx-select-oob swap-strategy capabilities (#1694)
The `hx-select-oob` attribute supports specifying a swap strategy but it's not publicly documented on the attribute page. This documents that behavior so that it's easy to discover.
Diffstat (limited to 'www/content/attributes')
-rw-r--r--www/content/attributes/hx-select-oob.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/www/content/attributes/hx-select-oob.md b/www/content/attributes/hx-select-oob.md
index 8983a542..4c13ac21 100644
--- a/www/content/attributes/hx-select-oob.md
+++ b/www/content/attributes/hx-select-oob.md
@@ -24,6 +24,23 @@ This button will issue a `GET` to `/info` and then select the element with the i
which will replace the entire button in the DOM, and, in addition, pick out an element with the id `alert`
in the response and swap it in for div in the DOM with the same ID.
+Each value in the comma separated list of values can specify any valid [`hx-swap`](@/attributes/hx-swap.md)
+strategy by separating the selector and the swap strategy with a `:`.
+
+For example, to prepend the alert content instead of replacing it:
+
+```html
+<div>
+ <div id="alert"></div>
+ <button hx-get="/info"
+ hx-select="#info-details"
+ hx-swap="outerHTML"
+ hx-select-oob="#alert:afterbegin">
+ Get Info!
+ </button>
+</div>
+```
+
## Notes
* `hx-select-oob` is inherited and can be placed on a parent element