我在文字输入上有一个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');