Skip to content

Commit

Permalink
docs(README): clarify API (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdtinney authored and Haroenv committed Oct 29, 2018
1 parent 4dc7c52 commit b6539d3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This JavaScript library adds a fast and fully-featured auto-completion menu to y
- [jQuery](#jquery)
- [Angular.JS](#angularjs)
- [Look and Feel](#look-and-feel)
- [Options](#options)
- [Global Options](#global-options)
- [Datasets](#datasets)
- [Sources](#sources)
- [Hits](#hits)
Expand Down Expand Up @@ -275,9 +275,9 @@ Here is what the [basic example](https://github.com/algolia/autocomplete.js/tree

![Basic example](./examples/basic.gif)

## Options
## Global Options

When initializing an autocomplete, there are a number of options you can configure.
When initializing an autocomplete, there are a number of global options you can configure.

* `autoselect` – If `true`, the first rendered suggestion in the dropdown will automatically have the `cursor` class, and pressing `<ENTER>` will select it.

Expand Down Expand Up @@ -635,12 +635,18 @@ All custom events are triggered on the element initialized as the autocomplete.

### jQuery

Turns any `input[type="text"]` element into an auto-completion menu. `options` is an
Turns any `input[type="text"]` element into an auto-completion menu. `globalOptions` is an
options hash that's used to configure the autocomplete to your liking. Refer to
[Options](#options) for more info regarding the available configs. Subsequent
[Global Options](#global-options) for more info regarding the available configs. Subsequent
arguments (`*datasets`), are individual option hashes for datasets. For more
details regarding datasets, refer to [Datasets](#datasets).

```
$(selector).autocomplete(globalOptions, datasets)
```

Example:

```js
$('.search-input').autocomplete({
minLength: 3
Expand Down Expand Up @@ -708,6 +714,12 @@ jQuery.fn._autocomplete = autocomplete;

The standalone version API is similiar to jQuery's:

```js
var search = autocomplete(containerSelector, globalOptions, datasets);
```

Example:

```js
var search = autocomplete('#search', { hint: false }, [{
source: autocomplete.sources.hits(index, { hitsPerPage: 5 })
Expand Down

0 comments on commit b6539d3

Please sign in to comment.