我想在从自动完成列表中选择后显示元素。
我的代码:
$(function () {
$("#SearchString").autocomplete({
messages: '',
source: '@Url.Action("GetProducts","Search")',
minLength: 2,
});
});
<div id="search" style="display:inline">
@using (Html.BeginForm("SearchProduct", "Search", FormMethod.Post, "null"))
{
@Html.TextBox("SearchString", null, new { id = "SearchString" })
<input type="submit" value="Search" id="Search" />
}
</div>
请分享您的建议。
答案 0 :(得分:0)
您需要添加select
自动填充事件:
$("#SearchString").autocomplete({
messages: '',
source: '@Url.Action("GetProducts","Search")',
minLength: 2,
select: function (i, j)
{
alert(j.item.value);
}
});
有关详细信息,请参阅自动填充documentation