mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2025-01-15 03:03:47 +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({
|
$('#autocomplete').autocomplete({
|
||||||
serviceUrl: '/autocomplete/countries',
|
serviceUrl: '/autocomplete/countries',
|
||||||
onSelect: function (suggestion) {
|
onSelect: function (suggestion) {
|
||||||
status.html('You selected: ' + suggestion);
|
alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Local lookup (no ajax):
|
Local lookup (no ajax):
|
||||||
|
|
||||||
|
var countries = [
|
||||||
|
{ value: 'Andorra', data: 'AD' },
|
||||||
|
// ...
|
||||||
|
{ value: 'Zimbabwe', data: 'ZZ' }
|
||||||
|
];
|
||||||
|
|
||||||
$('#autocomplete').autocomplete({
|
$('#autocomplete').autocomplete({
|
||||||
lookup: countries,
|
lookup: countries,
|
||||||
onSelect: function (suggestion) {
|
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 Format
|
||||||
|
|
||||||
Response from the server must be JSON formatted following JavaScript object:
|
Response from the server must be JSON formatted following JavaScript object:
|
||||||
|
Loading…
Reference in New Issue
Block a user