https://github.com/digitaledgeit/js-autosuggest
An auto suggest input.
https://github.com/digitaledgeit/js-autosuggest
Last synced: 6 months ago
JSON representation
An auto suggest input.
- Host: GitHub
- URL: https://github.com/digitaledgeit/js-autosuggest
- Owner: digitaledgeit
- Created: 2014-06-13T07:15:39.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-03-09T04:20:48.000Z (about 11 years ago)
- Last Synced: 2025-02-25T12:03:21.684Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 342 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# autosuggest
An auto suggest input.
## Installation
component install digitaledgeit/js-autosuggest
## Setup
var presenter = require('autosuggest')({
el: document.querySelector('.js-autosuggest'),
source: matcher(countries, {properties: ['name'], limit: 6, ignore_case: true}),
display: 'name',
template: function(query, country) {
return '
'+country.code+''+country.name+'';
},
minLength: 1,
hideDropDownIfEmpty: true,
listItemClasses: 'country'
});
## API
### new Autosuggest(options : object)
#### Options
- `hint` -
- `highlight` -
- `minlength` - The minimum number of characters the user must enter before any suggestions are fetched.
- `canSuggest` - A function that determines whether a suggestion should be made for the query
- `source` - A suggestion source - an array of suggestions, a `function(query : string)` that returns an array of suggestions or a `function(query : string, done : function(suggestions : array))` that calls the `done` method.
- `display` -
- `template` -
- selectItemWhenTabPressed - Select items when the user presses tab and an item in the drop down list is selected (using the arrow keys)
### .open()
Open the dropdown menu.
### .close()
Close the dropdown menu.
### .getValue()
Get the current input value.
### .setValue(value)
Set the current input value.
### .focus()
Focus the input element.
## Events
- `opened` - Triggered when the dropdown menu is opened.
- `closed` - Triggered when the dropdown menu is closed.
- `suggested` - Triggered when a suggestion is displayed in a dropdown. Passed the suggestion objects.
- `selected` - Triggered when a suggestion is selected from the dropdown. Passed the suggestion object.
- `blur` - Triggered
- `change` -
## Matcher
## Example
1. Run `component build --dev`
2. Open `test\example\countries.html`
## Test
1. Run `component build --dev`
2. Run `component test phantom`
## Troubleshooting
*Note*: Requires the following shims for IE8:
- bind
- classList
- indexOf
- event.preventDefault