我将以下代码用于自动完成功能。 如何将其更改为既可用于自动完成功能又可用于多选自动完成功能?
function AutoComplete(matchFieldName, resultFieldName, lookupURL) {
$('#' + matchFieldName).autocomplete({
minLength: 2, // set minimum of 2 characters before search executes.
delay: 500, // wait 0.5 second after keystroke before search executes.
source: function (request, response) {
$.ajax({
url: lookupURL,
type: "POST",
dataType: "json",
data: { AutoCompleteSearch: request.term },
success: function (data) {
response($.map(data, function (item) {
return { label: item.Title, value: item.Title, id: item.Id };
}))
}
});
},
select: function (event, ui) {
$('#' + resultFieldName).val(ui.item.id).trigger('change');
}
});
}