i'm using the jQuery UI with this code:
function initAutocomplete() {
$("#tbDevices").autocomplete("Static/ui.autocomplete/GetDevices.ashx", {
width: 160,
selectFirst: false,
max: 100,
autoFill: true,
matchContains: true,
highlightItem: true,
parse: function(data) {
return $.map(eval(data), function(row) {
return {
data: row,
lable: row.lable, //value being searched for
value: row.value //value in text input
}
});
},
formatItem: function(row, i, max, term) {
return "<span style='font-size: 110%;'>" + row.lable + "</span><br/>" + "ID: " + row.value;
},
formatResult: function(row, i, max) {
return row;
}
}).result(function(event, item) {
document.getElementById('#hdnChosenDevice').value = item.value;
$('#tbDevices').val(item.lable);
});
}
the ashx file is returning a string with json :
[{"lable":"device1","value":"01"},{"lable":"device2","value":"02"}]