У меня есть select2 для ввода текста, который позволяет выбрать несколько
Я не могу понять, как установить для него начальные значения, у меня есть код ниже. Любой указатель будет оценен. Спасибо.
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');