Skip to content

Commit

Permalink
Update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas Kirda committed Feb 23, 2015
1 parent 4ca8fc3 commit c9d106b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion readme.md
Expand Up @@ -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.
* `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.
* `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 }`.
* `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.
Expand Down Expand Up @@ -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

Generated HTML markup for suggestions is displayed bellow. You may style it any way you'd like.
Expand Down

0 comments on commit c9d106b

Please sign in to comment.