htmx icon indicating copy to clipboard operation
htmx copied to clipboard

hx-on with custom event is not working in the input tag

Open vitordeoliveira opened this issue 1 year ago • 3 comments

The following code

<input class="..." id="todo" name="todo" type="text" placeholder="Add Todo" hx-on:myevent="alert('me')">

is not working, if I use the custom event in ever other element it works fine.

vitordeoliveira avatar Feb 18 '24 07:02 vitordeoliveira

Hey, I tried and can't replicate the issue.

I tested htmx.trigger("#todo", "myevent") and it alerted me.

Are you sure you trigger the event on the correct element? Can you post more context?

andryyy avatar Feb 18 '24 12:02 andryyy

Can you show me how is your tag in the HTMX?

vitordeoliveira avatar Feb 18 '24 16:02 vitordeoliveira

Like andryyy, I can't replicate the issue either. See this JSFiddle with your input tag + the line andryyy mentioned above, I also get an alert as expected.

Telroshan avatar Feb 26 '24 17:02 Telroshan