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
Copy file name to clipboardexpand all lines: www/content/attributes/hx-history.md
+4
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
+++
2
2
title = "hx-history"
3
+
description = """\
4
+
The hx-history attribute in htmx allows you to prevent sensitive page data from being stored in the browser's \
5
+
localStorage cache during history navigation, ensuring that the page state is retrieved from the server instead when \
6
+
navigating through history."""
3
7
+++
4
8
5
9
Set the `hx-history` attribute to `false` on any element in the current document, or any html fragment loaded into the current document by htmx, to prevent sensitive data being saved to the localStorage cache when htmx takes a snapshot of the page state.
Copy file name to clipboardexpand all lines: www/content/attributes/hx-push-url.md
+3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,8 @@
1
1
+++
2
2
title = "hx-push-url"
3
+
description = """\
4
+
The hx-push-url attribute in htmx allows you to push a URL into the browser location history. This creates a new \
5
+
history entry, allowing navigation with the browser's back and forward buttons."""
3
6
+++
4
7
5
8
The `hx-push-url` attribute allows you to push a URL into the browser [location history](https://developer.mozilla.org/en-US/docs/Web/API/History_API).
Copy file name to clipboardexpand all lines: www/content/attributes/hx-replace-url.md
+2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
+++
2
2
title = "hx-replace-url"
3
+
description = """\
4
+
The hx-replace-url attribute in htmx allows you to replace the current URL of the browser location history."""
3
5
+++
4
6
5
7
The `hx-replace-url` attribute allows you to replace the current url of the browser [location history](https://developer.mozilla.org/en-US/docs/Web/API/History_API).
Copy file name to clipboardexpand all lines: www/content/attributes/hx-swap-oob.md
+8-4
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,13 @@
1
1
+++
2
2
title = "hx-swap-oob"
3
+
description = """\
4
+
The hx-swap-oob attribute in htmx allows you to specify that some content in a response should be swapped into the \
5
+
DOM somewhere other than the target, that is 'out-of-band'. This allows you to piggyback updates to other elements \
6
+
on a response."""
3
7
+++
4
8
5
9
The `hx-swap-oob` attribute allows you to specify that some content in a response should be
6
-
swapped into the DOM somewhere other than the target, that is "Out of Band". This allows you to piggy back updates to other element updates on a response.
10
+
swapped into the DOM somewhere other than the target, that is "Out of Band". This allows you to piggyback updates to other element updates on a response.
7
11
8
12
Consider the following response HTML:
9
13
@@ -72,7 +76,7 @@ A `<p>` can be encapsulated in `<div>` or `<span>`:
72
76
Note that you can use a `template` tag to encapsulate types of elements that, by the HTML spec, can't stand on their own in the
Here is an example with an out of band swap of a table row being encapsulated in this way:
79
+
Here is an example with an out-of-band swap of a table row being encapsulated in this way:
76
80
77
81
```html
78
82
<div>
@@ -91,7 +95,7 @@ Note that these template tags will be removed from the final content of the page
91
95
92
96
Some element types, like SVG, use a specific XML namespace for their child elements. This prevents internal elements from working correctly when swapped in, unless they are encapsulated within a `svg` tag. To modify the internal contents of an existing SVG, you can use both `template` and `svg` tags to encapsulate the elements, allowing them to get the correct namespace applied.
93
97
94
-
Here is an example with an out of band swap of svg elements being encapsulated in this way:
98
+
Here is an example with an out-of-band swap of svg elements being encapsulated in this way:
95
99
96
100
```html
97
101
<div>
@@ -111,7 +115,7 @@ Note that these `template` and `svg` wrapping tags will be removed from the fina
111
115
## Nested OOB Swaps
112
116
113
117
By default, any element with `hx-swap-oob=` attribute anywhere in the response is processed for oob swap behavior, including when an element is nested within the main response element.
114
-
This can be problematic when using [template fragments](https://htmx.org/essays/template-fragments/) where a fragment may be reused as a oob-swap target and also as part of a bigger fragment. When the bigger fragment is the main response the inner fragment will still be processed as an oob swap, removing it from the dom.
118
+
This can be problematic when using [template fragments](https://htmx.org/essays/template-fragments/) where a fragment may be reused as an oob-swap target and also as part of a bigger fragment. When the bigger fragment is the main response the inner fragment will still be processed as an oob swap, removing it from the dom.
115
119
116
120
This behavior can be changed by setting the config `htmx.config.allowNestedOobSwaps` to `false`. If this config option is `false`, OOB swaps are only processed when the element is *adjacent to* the main response element, OOB swaps elsewhere will be ignored and oob-swap-related attributes stripped.
0 commit comments