プロジェクトでjquery-UIオートコンプリートを使用していますが、正常に動作しています。コードは次のとおりです
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$(".tags").autocomplete({
source: function (request, response) {
loc_array = request.term.split(',');
var term = loc_array[loc_array.length - 1];
$.ajax({
url: "/Admin/Tag1/LookUpCompany",
dataType: "json",
data: "q=" + term,
success: function (data) {
response($.map(data, function (item) {
return {
value: item.Name,
Name: item.Name
};
}));
}
});
},
select: function (event, ui) {
event.preventDefault();
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
// terms.push( "" );
this.value = terms.join( "," );
return false;
},
minLength: 1
});
正常に動作していますが、ページを読み込んだときにテキストボックスに値があると仮定すると問題があります
abc,def,ghi,
任意の文字を入力すると、ドロップダウンの形式で提案が表示されます。それをクリックすると、クリックした値に現在の値が追加されますが、キーボードの下キーを使用して下に移動すると、textbpx 値全体が現在選択されている値に変更されます。それを修正する方法?
ありがとう 、