I'm trying to pre populate selected options using 'val', but I'm getting only one option as preselected in the options. JSFiddle code
<select name="question_tags[]" id="question_tags" class="select2_tags" multiple="multiple">
$(document).ready(function() {
$('.select2_tags').select2({
placeholder:"Select",
data : ["Data Structure", "DBMS", "OS"]
}).select2('val', ["OS", "DBMS"]);
});
I'm using select2 v4.06
I explored it, and found the functionalities implemented for the previous version of select2, which is now deprecated in recent versions Existing solutions JSFiddle
The solution in the link is not working for current version of select2, How to pre-select values in select2 multi select?