It is only attatched to the fist one of the multiple triggers. Here is an example codepen: https://codepen.io/viggiesmalls/pen/NWoRryY
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://unpkg.com/[email protected]" integrity="sha384-FhXw7b6AlE/jyjlZH5iHa/tTe9EpJ1Y55RjcgPbjeWMskSxZt1v9qkxLJWNJaGni" crossorigin="anonymous"></script>
<script>
function logEvent(evt) {
console.log(evt)
}
</script>
</head>
<body>
<input type="text" hx-post="/hx/validate" hx-vals="js:{value: logEvent(event)}" hx-trigger="keyup,change delay:200ms changed" hx-target="next .errors">
<div class="errors"></div>
</body>
</html>
The exaple above only logs the "event" object on the keyup event, but not on change ( when I click away from the input field) If I swap change and keyup like this:
hx-trigger="change, keyup delay:200ms changed"
then the "event" object is only attatched to the change event, and not the keyup event.
Why is that? What would be the correct way to to specify hx-trigger
in order to have the "event" object attached to both, and a delay of 200ms?
I think this is htmx issue with evaluating js for hx-vals when using delayed triggers.
More details can be found here: https://github.com/bigskysoftware/htmx/issues/1658
The workaround may be to use debounce inside the evaluated js function fo now, until the case is handled properly in the future versions.