mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2025-01-14 18:59:46 +00:00
Update samples, add styling
This commit is contained in:
parent
459719fc02
commit
b6fedc2dbd
20
readme.md
20
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.
|
||||
|
||||
<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:
|
||||
|
Loading…
Reference in New Issue
Block a user