My current code is as follows:
$(document).ready(function () {
$('#txtSearchForTrainingFacility').autocomplete({
select: function (event, ui) {
searchCallback(event, ui);
},
source: function (request, response) {
$.ajax({
url: 'http://localhost:49795/Ajax/Search/' + $('#txtSearchForTrainingFacility').val(),
dataType: 'json',
data: {},
success: function (data) {
response( $.map( data, function( item ) {
return {
label: item.Name,
value: item.Value,
id: item.ID
}
}))
}
})
}
});
});
You can see that in the event function ajax.successI return an object with objects label, valueand id, but the parameter autocomplete.select ui.itemcontains only labeland value.
What am I doing wrong? How can I get a property idto display in an object autocomplete.select ui.item?
the result of calling ajax is a json array, each element of which contains properties Name, valueand id.
Note
If you replace the ajax call with a fixed array [{id: 1, label: 'bob', value: 'creep'}, {id: 2, label: 'joe', value: 'friend'}], then the property idseems to go through the select event just fine.