Hello.
I’m trying to programmatically change a value from a select2 that uses remote data but it has no effect, the value is not changed.
You call test it as well at the official docs link: https://select2.org/data-sources/ajax
The code i use is the one bellow:
$(".js-example-data-ajax").val('39840932').trigger('change.select2')
.
the value ‘39840932’ represents the google/googletest option from the select.
One thing I noticed that this code above works only if you follow the steps:
- manually select the google/googletest option from the select
- manually change for any other option
- run the code above
Looks like it needs the data to come from the server and then you can programmatically change its value, but it should not be this way