2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-26 06:46:32 +00:00

Update documentation.

This commit is contained in:
Tomas Kirda 2013-04-24 16:34:33 -05:00
parent 997a4b92cc
commit 3512a4aaec

View File

@ -12,7 +12,7 @@ The standard jquery.autocomplete.js file is around 2.7KB when minified via Closu
* `$(selector).autocomplete(options);` * `$(selector).autocomplete(options);`
* Sets up autocomplete for input field(s). * Sets up autocomplete for input field(s).
* `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 that provides results for suggestions. 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.
* `lookup`: Lookup array for the suggestions. It may be array of strings or `suggestion` object literals. * `lookup`: 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).
@ -39,6 +39,27 @@ The standard jquery.autocomplete.js file is around 2.7KB when minified via Closu
* `appendTo`: container where suggestions will be appended. Default value `body`. Can be jQuery object, selector or html element. Make sure to set `position: absolute` or `position: relative` for that element. * `appendTo`: container where suggestions will be appended. Default value `body`. Can be jQuery object, selector or html element. Make sure to set `position: absolute` or `position: relative` for that element.
* `dataType`: type of data returned from server. Either 'text' (default) or 'jsonp', which will cause the autocomplete to use jsonp. You may return a json object in your callback when using jsonp. * `dataType`: type of data returned from server. Either 'text' (default) or 'jsonp', which will cause the autocomplete to use jsonp. You may return a json object in your callback when using jsonp.
Autocomplete instance has following methods:
* `setOptions(options)`: you may update any option at any time. Options are listed above.
* `clear`: clears suggestion cache and current suggestions suggestions.
* `clearCache`: clears suggestion cache.
* `disable`: deactivate autocomplete.
* `enable`: activates autocomplete if it was deactivated before.
* `hide`: hides suggestions.
* `dispose`: destroys autocomplete instance. All events are detached and suggestion containers removed.
There are two ways that you can invoke Autocomplete method. One is calling autocomplete on jQuery object and passing method name as string literal.
If method has arguments, arguments are passed as consecutive parameters:
$('#autocomplete').autocomplete('disable');
$('#autocomplete').autocomplete('setOptions', options);
Or you can get Autocomplete instance by calling autcomplete on jQuery object without any parameters and then invoke desired method.
$('#autocomplete').autocomplete().disable();
$('#autocomplete').autocomplete().setOptions(options);
##Usage ##Usage
Html: Html: