2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-22 12:55: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) { lookup: function (query, done) {
// Do ajax call or lookup locally, when done, // Do ajax call or lookup locally, when done,
// call the callback and pass your results: // call the callback and pass your results:
var results = [ var result = {
suggestions: [
{ "value": "United Arab Emirates", "data": "AE" }, { "value": "United Arab Emirates", "data": "AE" },
{ "value": "United Kingdom", "data": "UK" }, { "value": "United Kingdom", "data": "UK" },
{ "value": "United States", "data": "US" } { "value": "United States", "data": "US" }
]; ]
};
done(results); done(result);
}, },
onSelect: function (suggestion) { onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + ', ' + suggestion.data); alert('You selected: ' + suggestion.value + ', ' + suggestion.data);