我有麻烦试图让自动完成工作正常.
这一切看起来都不错,但......
<script>
$(function () {
$("#customer-search").autocomplete({
source: 'Customer/GetCustomerByName',
minLength: 3,
select: function (event, ui) {
$("#customer-search").val(ui.item.label);
$("#selected-customer").val(ui.item.label);
}
});
});
</script>
<div>
<input id="customer-search" />
</div>
@Html.Hidden("selected-customer")
Run Code Online (Sandbox Code Playgroud)
但是,当我从下拉列表中选择一个项目时,该值已应用于文本框而不是标签.
我做错了什么?
如果我使用firebug查看源代码,我可以看到我的隐藏字段正在正确更新.
asp.net-mvc jquery jquery-ui autocomplete jquery-ui-autocomplete