Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(README): clarify API #261

Merged
merged 2 commits into from
Oct 29, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
docs(README): clarify API
cdtinney committed Oct 27, 2018
commit 5fde8d3b9ab2d244eb6302b8304570517a976e50
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
@@ -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.

@@ -632,12 +632,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
@@ -705,6 +711,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 })