So I have a jquery autocomplete on a testbox that searches the database for a user, and places the ID in a hidden input field. For some reason the autocomplete fires when they type something, then again when an item is selected, changing the text. Since I'm searching first and last name it doesn't find any matches the second time and clears my field out.
I have it working on a separate page, but that only searches one field, so when it returns back a value it stays. This however searches two fields, so when it goes to search a second time it doesn't return anything. I believe the problem lies there, but I don't know how to fix it.
$("#FormSubscriberName").autocomplete('/subscriber/search', {
autoFill: false,
mustMatch: true,
matchContains: true,
cacheLength: 12,
formatItem: function (data, index, max) {
return data[1];
},
formatMatch: function (data, index, max) {
return data[1];
},
formatResult: function (data, index, max) {
return data[1];
}
}).result(function (event, data, formatted) {
if (data) {
$("#SubscriberID").val(data[0]);
$("#FormSubscriberName").val(data[1]);
}
else {
$("#SubscriberID").val('<%= Guid.Empty %>');
}
});
<input id="FormSubscriberName" name="FormSubscriberName" style="width:250px;" type="text" value="" />
<input id="SubscriberID" name="SubscriberID" type="hidden" value="" />