MVC3 Web プロジェクトで ui jquery auto-complete を使用し、jquery を外部 js ファイルに保持して Web ページに含めましたが、機能していません。
ui jquery auto-complete の js ファイルで次のコードを使用しました。
$(function () {
$("#ReportsTo_FullName").autocomplete({
source: function (request, response) {
var linkPath = "@Html.Raw(Url.Action("AutocompleteSuggestions", "Employee", new { @term = "Term", @moduleName="ModuleName"}))";
linkPath = linkPath.replace("Term", request.term);
linkPath = linkPath.replace("ModuleName", "Employee");
$.post(linkPath, function (data) {
response($.map(data, function (item) {
return { label: item.FullName, value: item.Id }
}
));
})
$.error(function (xhr, ajaxOptions, thrownError) { alert(thrownError); })
},
minLength: 1,
focus: function (event, ui) {
$("#ReportsTo_FullName").val(ui.item.label);
return false;
},
select: function (event, ui) {
if (ui.item) {
$("#ReportsTo_FullName").css('border', '');
$("#ReportsTo_FullName").val(ui.item.label);
$("#ReportsToId").val(ui.item.value);
return false;
}
},
change: function (event, ui) {
if (ui.item == null) {
$("#ReportsTo_FullName").css({ 'border': '1px solid #ff0000' });
$("#ReportsToId").val(null);
}
}
});
});
しかし、実行に失敗し、オートコンプリートが表示されません。
上記の jquery で何が問題になっていますか?
この問題を解決するには?