Hello,
I have got this working with a local data source but not remotely. It uses the Jquery library and I have followed the instructions on the Jquery UI site. This is the code I have (which does not work). Can anyone a) amend this code to work b) show code of a working example?? Thanks:
JQUERY
$('#countries').autocomplete({
source: "/Trip/Lookup",
minLength: 0,
focus: function (event, ui) {
$('#countries').val(ui.item.label);
return false;
},
select: function (event, ui) {
return false;
}
}).data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
ACTIONRESULT
public ActionResult Lookup(string q, int limit)
{
List<DestinationVM> list = new List<DestinationVM>();
list.Add(new DestinationVM { Destination = "England", Cost = 12 });
list.Add(new DestinationVM { Destination = "New Zealand", Cost = 10 });
list.Add(new DestinationVM { Destination = "Australia", Cost = 8 });
var data = from s in list select new { s.Destination, s.Cost };
return Json(data);
}