From b6fedc2dbdab6adec6e568a60d48ec4b0fab86f2 Mon Sep 17 00:00:00 2001 From: Tomas Kirda Date: Tue, 18 Dec 2012 18:03:45 -0600 Subject: [PATCH] Update samples, add styling --- readme.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 1a8ab42..436a92f 100644 --- a/readme.md +++ b/readme.md @@ -15,19 +15,35 @@ Ajax lookup: $('#autocomplete').autocomplete({ serviceUrl: '/autocomplete/countries', onSelect: function (suggestion) { - status.html('You selected: ' + suggestion); + alert('You selected: ' + suggestion.value + ', ' + suggestion.data); } }); Local lookup (no ajax): + var countries = [ + { value: 'Andorra', data: 'AD' }, + // ... + { value: 'Zimbabwe', data: 'ZZ' } + ]; + $('#autocomplete').autocomplete({ lookup: countries, onSelect: function (suggestion) { - status.html('You selected: ' + suggestion); + alert('You selected: ' + suggestion.value + ', ' + suggestion.data); } }); +##Styling + +Generated HTML markup for suggestions is displayed bellow. You may style it any way you'd like. + +
+
...
+
...
+
...
+
+ ##Response Format Response from the server must be JSON formatted following JavaScript object: