diff options
author | Simon Hartley <170740+scrhartley@users.noreply.github.com> | 2025-01-08 08:13:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-08 09:13:31 +0100 |
commit | 906299602552afddcd16cc384c0dda690a127745 (patch) | |
tree | a5e5aca49f253ddda81337517f4f9dbc64935c5a | |
parent | 271a3869c5732f2511addcb35b6e280c21eda78c (diff) | |
download | htmx-906299602552afddcd16cc384c0dda690a127745.tar.gz htmx-906299602552afddcd16cc384c0dda690a127745.zip |
[Documentation] Make htmx:beforeSwap more complete (#3110)
Co-authored-by: scrhartley <scrhartley@github.com>
-rw-r--r-- | www/content/events.md | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/www/content/events.md b/www/content/events.md index 568ec94e..39a054b6 100644 --- a/www/content/events.md +++ b/www/content/events.md @@ -126,10 +126,12 @@ This event is triggered right before a request is sent. You may not cancel the ### Event - `htmx:beforeSwap` {#htmx:beforeSwap} -This event is triggered before any new content has been [swapped into the DOM](@/docs.md#swapping). If you call `preventDefault()` on the event to cancel it, no swap will occur. +This event is triggered before any new content has been [swapped into the DOM](@/docs.md#swapping). +Most values on `detail` can be set to override subsequent behavior, other than where response headers take precedence. +If you call `preventDefault()` on the event to cancel it, no swap will occur. -You can modify the default swap behavior by modifying the `shouldSwap` and `target` properties of the event detail. See -the documentation on [configuring swapping](@/docs.md#modifying_swapping_behavior_with_events) for more details. +You can modify the default swap behavior by modifying the `shouldSwap`, `selectOverride`, `swapOverride` and `target` properties of the event detail. +See the documentation on [configuring swapping](@/docs.md#modifying_swapping_behavior_with_events) for more details. ##### Details @@ -139,6 +141,10 @@ the documentation on [configuring swapping](@/docs.md#modifying_swapping_behavio * `detail.requestConfig.elt` - the element that dispatched the request * `detail.shouldSwap` - if the content will be swapped (defaults to `false` for non-200 response codes) * `detail.ignoreTitle` - if `true` any title tag in the response will be ignored +* `detail.isError` - whether error events should be triggered and also determines the values of `detail.successful` and `detail.failed` in later events +* `detail.serverResponse` - the server response as text to be used for the swap +* `detail.selectOverride` - add this to use instead of an [`hx-select`](@/attributes/hx-select.md) value +* `detail.swapOverride` - add this to use instead of an [`hx-swap`](@/attributes/hx-swap.md) value * `detail.target` - the target of the swap ### Event - `htmx:beforeTransition` {#htmx:beforeTransition} |