mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-02 15:25:26 +00:00
Update hx-trigger.md
Added an example without using JS code for better modifier understanding for basic body trigger call
This commit is contained in:
parent
2dae703d55
commit
badc733d5b
@ -27,6 +27,13 @@ document.body.addEventListener("myEvent", function(evt){
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
... or like this, if you're trying to trigger some element without using JS code:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- Since it bubbles up to the <body>, we must use the `from:body` modifier below -->
|
||||||
|
<div hx-trigger="myEvent from:body" hx-get="/example"></div>
|
||||||
|
```
|
||||||
|
|
||||||
If you want to pass details along with the event, you can move to JSON for the value of the trigger:
|
If you want to pass details along with the event, you can move to JSON for the value of the trigger:
|
||||||
|
|
||||||
`HX-Trigger: {"showMessage":"Here Is A Message"}`
|
`HX-Trigger: {"showMessage":"Here Is A Message"}`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user