Skip to content

pirxpilot/autosuggest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autosuggest

Autosuggest values for text inputs

<input type="text"> autosuggest component. Try the demo!

Inspired from http://oak.cs.ucla.edu/cs144/projects/javascript/suggest1.html.

Installation

$ component install component/autosuggest

Example

var autosuggest = require('autosuggest');
var input = document.querySelector('input[type="text"]');

// array of suggestions
var suggestions = [
  'Sunday',
  'Monday',
  'Tuesday',
  'Wednesday',
  'Thursday',
  'Friday',
  'Saturday'
];

// create an `autosuggest` instance
var suggest = autosuggest(input, suggestions);

// and you can change the array of suggestions to use if they get change
var newSuggestions = suggestions.concat([ 'Funday' ]);
suggest.set(newSuggestions);

API

autosuggest(el, [suggestions]) → Autosuggest

Returns an Autosuggest instance. The instance has .start() called on it if the optional suggestions array is given, otherwise you must call .set(array) and .start() manually.

.set(array)

Sets a new array of Strings to use as the suggestions for the Autosuggest instance.

.start()

Starts the autosuggesting for the Autosuggest instance.

.stop()

Stops the autosuggesting for the Autosuggest instance..

License

MIT

About

Autosuggest values for text inputs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 80.6%
  • HTML 13.6%
  • Makefile 5.8%