Trigger select change

hi everyone,
My select change trigger configuration
and in my controller I have the categoryChanged method created, but my select can be changed programmatically. So I’m wondering if Stimulus have the onChange event how can I trigger it without create a new javascript eventListener.

thanks and advance.

I was able to do this by doing element.dispatchEvent(new Event(‘change’))
Hope it helps

1 Like

I end up with this solution

[name]Target.dispatchEvent(new Event('change'));

It seems like that Stimulus create the eventListener based on naming conventions, i.e, you can trigger the events by their stimulus name.

you edited your answer while I was posting my answer, but yes, that was my solution too

yeah, thanks :slight_smile: