mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-30 06:21:19 +00:00
Docs: add hx-vals example using the event object (#825)
This commit is contained in:
parent
f302ad6fdd
commit
c49ce64d2d
@ -18,6 +18,14 @@ If you wish for `hx-vals` to *evaluate* the values given, you can prefix the val
|
||||
<div hx-get="/example" hx-vals='js:{myVal: calculateValue()}'>Get Some HTML, Including a Dynamic Value from Javascript in the Request</div>
|
||||
```
|
||||
|
||||
When using evaluated code you can access the `event` object. This example includes the value of the last typed key within the input.
|
||||
|
||||
```html
|
||||
<div hx-get="/example" hx-trigger="keyup" hx-vals='js:{lastKey: event.key}'>
|
||||
<input type="text" />
|
||||
</div>
|
||||
```
|
||||
|
||||
### Security Considerations
|
||||
|
||||
* By default, the value of `hx-vals` must be valid [JSON](https://developer.mozilla.org/en-US/docs/Glossary/JSON).
|
||||
|
Loading…
x
Reference in New Issue
Block a user