mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 23:35:13 +00:00
X-IC-Redirect implementation
This commit is contained in:
parent
84200f4599
commit
17c3f74e0c
19
www/docs.md
19
www/docs.md
@ -631,6 +631,25 @@ In hyperscript similar functionality is implemented like so:
|
|||||||
</body>
|
</body>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### `X-IC-Redirect`
|
||||||
|
|
||||||
|
Intercooler provided more response headers than htmx does: `X-IC-Refresh`, `X-IC-Redirect` etc. Htmx omits these
|
||||||
|
headers in favor of the general `HX-Trigger`, combined with some client side code.
|
||||||
|
|
||||||
|
Let's implement the `X-IC-Redirect` header using the `HX-Trigger` response header and some hyperscript.
|
||||||
|
|
||||||
|
First, let's trigger an event with a response header that looks like this:
|
||||||
|
|
||||||
|
`HX-Trigger:{"redirect":{"url":"https://htmx.org"}}`
|
||||||
|
|
||||||
|
Then we would write the following hyperscript:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<body _="on redirect(url) put url into window.location">
|
||||||
|
...
|
||||||
|
</body>
|
||||||
|
```
|
||||||
|
|
||||||
##### `ic-switch-class`
|
##### `ic-switch-class`
|
||||||
|
|
||||||
Intercooler provided the [`ic-switch-class`](http://intercoolerjs.org/attributes/ic-switch-class.html) attribute, which
|
Intercooler provided the [`ic-switch-class`](http://intercoolerjs.org/attributes/ic-switch-class.html) attribute, which
|
||||||
|
Loading…
x
Reference in New Issue
Block a user