bigskysoftware / bigskysoftware/htmx
htmx:confirm with custom event drop hx-vals parameters when triggered by htmx.trigger
- Dominant language
- JavaScript
- Stars
- 49.4k
- Forks
- 1.7k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 30
Description
If an event listener is placed on "htmx:confirm" and then a issueRequest() is made the custom event parameters are lost from the htmx.trigger. If the issueRequest() is commented out the parameters are correctly passed through.
I just want to confirm this is correct usage for having a condition in "htmx:confirm" to cancel a request or allowing it.
I haven't investigated why issueRequest is doing this, but I assume the default behaviour would be the calling of this function.
[jsfiddle](https://jsfiddle.net/tatebluedogcomau/em1kqz2c/58/#&togetherjs=le72nyODv0)
```
document.body.addEventListener("htmx:load", function() {
htmx.trigger("#count", "count", { number: 10 })
})
document.body.addEventListener("htmx:confirm", async function (event) {
event.preventDefault()
// some condition to determine if the request will be made or cancelled
await event.detail.issueRequest()
})
Count Up
${JSON.stringify(params)}
```
Contributor guide
Assessment
This issue has not been assessed yet.