2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-22 04:45:12 +00:00

Update lookup sample code, closes #329

This commit is contained in:
Tomas Kirda 2015-03-16 11:20:59 -05:00
parent 5f7f91af0b
commit 82abff9f3c

View File

@ -123,13 +123,15 @@ $('#autocomplete').autocomplete({
lookup: function (query, done) {
// Do ajax call or lookup locally, when done,
// call the callback and pass your results:
var results = [
{ "value": "United Arab Emirates", "data": "AE" },
{ "value": "United Kingdom", "data": "UK" },
{ "value": "United States", "data": "US" }
];
var result = {
suggestions: [
{ "value": "United Arab Emirates", "data": "AE" },
{ "value": "United Kingdom", "data": "UK" },
{ "value": "United States", "data": "US" }
]
};
done(results);
done(result);
},
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + ', ' + suggestion.data);