DEV Community

Discussion on: Rails 6, Stimulus and Select2

Collapse
 
justinmcodes profile image
jmarsh24

Could you add to this guide how to fire native events with select2?

Collapse
 
ronakabhattrz profile image
Ronak Bhatt

You can do bro please chek this Link for Select2 Events

Collapse
 
justinmcodes profile image
jmarsh24

I figured out how.

.on("select2:select", function() {
let event = new Event('change', { bubbles: true })
this.dispatchEvent(event)

I was just asking because I think it might be useful for the guide.

Thread Thread
 
ronakabhattrz profile image
Ronak Bhatt

Great will DO it Thanks :) 😊