I’m currently in the process of converting our vanilla js to stimulus controllers. I have a select dropdown on which I have attached select2. Everything is working fine except one thing. When trying to change the value of the dropdown in a .js.erb view like this
$("#new_order_sender").val("<%= @sender.id %>").trigger('change.select2'); it doesn’t trigger the change nor does it change the value. It seems to me that select2 is not available globally in the browser and that is causing the issue but I’m not 100% sure. Anyone had the same problem or something similar?