0
我正在使用jQuery UI自動填充並使其部分工作。當找不到結果時,它會顯示我的「未找到結果」。消息沒有問題,但是當找到結果時,它僅顯示每個選項的空白框,根本沒有文本。jQuery UI自動填充不填充文本的選擇列表
我已經調試並沒有什麼開發者控制檯顯示,我可以深入到我的ASP.Net代碼,看看有效數據得到拉動。我在這裏錯過了什麼?
的jQuery:
$("#ProjectSearchBox").autocomplete(
{
minLength: 3,
source: function(request, response)
{
$.ajax(
{
cache: false,
type: "GET",
url: "/Timesheet/ProjectCodes?searchTearm=" + request.term,
success: function(data)
{
response(data);
},
error: function(xhr)
{
alert("Error getting project list, please try again later.");
}
});
}
});
HTML:
<li>
<label for="ProjectSearchBox">Search Project:</label>
<input type="text" id="ProjectSearchBox" name="ProjectSearchBox" list="ProjectList" />
</li>
ASP.Net代碼:
var projects = db.ProjectCodes
.Where(project => project.Code.ToLower().Contains(searchTearm.ToLower()) || project.Description.ToLower().Contains(searchTearm.ToLower()))
.Select(project => new
{
projectInfo = string.Concat(project.Code, " | ", project.Description)
}).ToList();
if (projects.Count == 0)
{
return Json(new { responseText = "No match found." }, JsonRequestBehavior.AllowGet);
}
else
{
return Json(projects, JsonRequestBehavior.AllowGet);
}
這是問題,謝謝 – Matthew