2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2025-01-14 10:53:08 +00:00

Update samples, add styling

This commit is contained in:
Tomas Kirda 2012-12-18 18:03:45 -06:00
parent 459719fc02
commit b6fedc2dbd

View File

@ -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.
<div class="autocomplete">
<div class="autocomplete-suggestion autocomplete-selected">...</div>
<div class="autocomplete-suggestion">...</div>
<div class="autocomplete-suggestion">...</div>
</div>
##Response Format
Response from the server must be JSON formatted following JavaScript object: