2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2025-01-03 14:47:25 +00:00

Update documentation.

This commit is contained in:
Tomas Kirda 2015-02-23 15:12:33 -06:00
parent 4ca8fc3c5b
commit c9d106ba79

View File

@ -14,7 +14,7 @@ The standard jquery.autocomplete.js file is around 2.7KB when minified via Closu
* `options`: An object literal which defines the settings to use for the autocomplete plugin. * `options`: An object literal which defines the settings to use for the autocomplete plugin.
* `serviceUrl`: Server side URL or callback function that returns serviceUrl string. Optional if local lookup data is provided. * `serviceUrl`: Server side URL or callback function that returns serviceUrl string. Optional if local lookup data is provided.
* `ajaxSettings`: Any additional [Ajax Settings](http://api.jquery.com/jquery.ajax/#jQuery-ajax-settings) that configure the jQuery Ajax request. * `ajaxSettings`: Any additional [Ajax Settings](http://api.jquery.com/jquery.ajax/#jQuery-ajax-settings) that configure the jQuery Ajax request.
* `lookup`: Lookup array for the suggestions. It may be array of strings or `suggestion` object literals. * `lookup`: Callback function or lookup array for the suggestions. It may be array of strings or `suggestion` object literals.
* `suggestion`: An object literal with the following format: `{ value: 'string', data: any }`. * `suggestion`: An object literal with the following format: `{ value: 'string', data: any }`.
* `lookupFilter`: `function (suggestion, query, queryLowerCase) {}` filter function for local lookups. By default it does partial string match (case insensitive). * `lookupFilter`: `function (suggestion, query, queryLowerCase) {}` filter function for local lookups. By default it does partial string match (case insensitive).
* `lookupLimit`: Number of maximum results to display for local lookup. Default: no limit. * `lookupLimit`: Number of maximum results to display for local lookup. Default: no limit.
@ -115,6 +115,27 @@ $('#autocomplete').autocomplete({
}); });
``` ```
Custom lookup function:
```javascript
$('#autocomplete').autocomplete({
lookup: function (query, done) {
// Do ajax call or lookup locally, when done,
// call the callback and pass your results:
var results = [
{ "value": "United Arab Emirates", "data": "AE" },
{ "value": "United Kingdom", "data": "UK" },
{ "value": "United States", "data": "US" }
];
done(results);
},
onSelect: function (suggestion) {
alert('You selected: ' + suggestion.value + ', ' + suggestion.data);
}
});
```
##Styling ##Styling
Generated HTML markup for suggestions is displayed bellow. You may style it any way you'd like. Generated HTML markup for suggestions is displayed bellow. You may style it any way you'd like.