I have a select2 on text input that allow multiple selected
I can't figure out how to set the initial values for it, I have below code. Any pointer would be appreciated. Thank you.
var $select = $('#cc_list');
$select.select2({
placeholder: "Search CC list",
minimumInputLength: 1,
ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
url: "../ajax/employee-select2.php",
dataType: 'json',
quietMillis: 250,
data: function (term, page) {
return {
query: term, // search term
};
},
results: function (data, page) { // parse the results into the format expected by Select2.
return { results: data };
},
cache: true
},
multiple: true,
maximumSelectionSize: 5,
dropdownCssClass: "bigdrop",
escapeMarkup: function (m) { return m; }
});
$select.val('val1, val2').trigger('change');