How to populate select2 with dynamically created tags?
I’m following this instruction:
https://select2.org/tagging
I have dynamic tags being created when user types text into input by hand.
I would like to set some default tags when page is loaded with code.
$("#tagiField").val(‘something’);
$("#tagiField").append(‘anything’);
<select id="tagiField"
class="js-states form-control js-example-basic-multiple js-example-tags js-example-responsive"
name="states[]"
multiple="multiple"
style="width: 100%">
</select>
Seems like a basic thing, but I failed. Any help appeciated.