Im having troubles trying to get the autocomplete to work properly.
It all looks ok to me but....
<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")
However when I select an item from the dropdown the value is been applied to the textbox instead of the label.
What have I done wrong?
If I look at the source using firebug I can see that my hidden field is being updated correctly.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…