0
我在我的MVC3 web项目中使用了ui jquery auto-complete,并将jquery保存在外部js文件中,并将其包含在网页中,但它不起作用。如何用户@ Html.Raw不工作在UI jQuery自动完成?
我用下面的代码在js文件的用户界面的jQuery自动完成:
$(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有什么错?
如何解决此问题?
要解决这个问题,你应该先做一些研究。您可以查看[this](http://stackoverflow.com/q/7902213/944681),[this](http://stackoverflow.com/q/4599169/944681)或[this](http:// www .google.com)的首发.. –