I am using Select2's tags (similar to Stackoverflow's tags) in a Spring MVC application. I am trying to load the tags which are already in the field, and then some more which aren't in it yet. The field only shows the last one in its values list though. How can I make the other ones appear as well?
This is an example of my current code:
<select id="tags" class="js-example-responsive" style="width: 50%" name="tags">
<option selected="selected" value="foo">foo</option>
<option selected="selected" value="gnoo">gnoo</option>
<option selected="selected" value="blaat">blaat</option>
<option selected="selected" value="blaatbeest">blaatbeest</option>
</select>
My javascript code:
$('#tags').select2({
tags: true,
multiple:true,
data:['foo','gnoo','blaat','gnooooo', 'blaatbeest']
});
Use multiple="multiple"
attribute in select tag
<select id="tags" class="js-example-responsive" style="width: 50%" name="tags" multiple="multiple">