hx-trigger with custom event triggers on other events #3245
|
I'm dispatching an event from an alpine.js component like so: Then I'm using the event as a trigger like this: <div hx-post="/login" hx-trigger="auth from:body" hx-vals="js:{...event.detail}">
<input type="text" hx-post="/check-username" hx-trigger="changed">
</div>The issue is that the input change triggers the parent div hx-vals evaluation; I get an error that 'detail' is undefined. Is this expected? I thought the parent div would only trigger from the "auth" event. |
Replies: 2 comments
|
Hey, Also, is it expected to use Hope this helps! |
|
Okay, thanks for the help! |
Hey,
hx-vals is inherited by default, which is likely why you're getting it evaluated for the child input ; I think that instead of being the parent div that gets its
hx-valsevaluated, it's simply theinputthat inherits thehx-valsfrom its parent div, thus gets its evaluated for itself.I think you could add
hx-vals="unset"to your input to fix thisAlso, is it expected to use
hx-trigger="changed"here? You might want to use the standard eventchangeinstead, aschangedis a modifier keyword that htmx supports, but that still has to complement an event nameHope this helps!