In my ASP MVC view, I am passing a key/value pair back from the controller. After looking at fiddler and viewing in Chrome\'s debugger I can see that the information is bein
You'll need to make the AJAX request yourself and transform the data to the format that jQueryUI expects:
$(function () {
$('#DRMCompanyId').autocomplete({
source: function (request, response) {
$.ajax({
url: '@Url.Action("compSearch", "AgentTransmission")',
type: 'GET',
dataType: 'json',
data: request,
success: function (data) {
response($.map(data, function (value, key) {
return {
label: value,
value: key
};
}));
}
});
},
minLength: 2
});
});
Also, the value property of an autocomplete item is automatically placed in the input when that item is selected, so there should be no need for a custom select handler.
Example: http://jsfiddle.net/Aa5nK/60/