show separate tags instead of one if the selected options value has comma in it

12 views
Skip to first unread message

aitus...@gmail.com

unread,
Feb 5, 2017, 10:50:26 AM2/5/17
to select2
i have a select2 multiple input. generally it works fine, when i select any option it will apear as token. what i want is, when an option is selected and if the options value has comma in it, it should split the value and it should apear as multiple tokens instead of one in the box. but i dont want any change in the dropdown list.

here is my current code:

<div class="tags-select2-area">
<select id="tags" multiple="multiple">
<option selected="selected">
Kerry
</option>
<option selected="selected">
Cork
</option>
</select>
</div>

<script>
$('#tags').select2({
data: ["Clare", "Cork", "South Dublin", "netagenda, Programmierung, 2.3.0"],
tags: true,
tokenSeparators: [','],
placeholder: "Add your tags here",
allowClear: true, //Task 4 =============
});

</script>

jsfiddle : https://jsfiddle.net/ai_tushar/rxvhvcke/

please help

Reply all
Reply to author
Forward
0 new messages