Socket
Socket
Sign inDemoInstall

autocomplete-element

Package Overview
Dependencies
1
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    autocomplete-element

autocomplete for elements


Version published
Weekly downloads
31
decreased by-35.42%
Maintainers
1
Install size
17.9 kB
Created
Weekly downloads
 

Readme

Source

autocomplete-element

Wire up autocomplete for an <input type="text"> element.

example

Try this example.

Auto-complete the months.

var auto = require('autocomplete-element');
var input = document.querySelector('input');

var months = [
    "January", "February", "March", "April", "May", "June", "July",
    "August", "September", "October", "November", "December"
];
auto(input, function (c) {
    if (!input.value.length) return c.suggest([]);
    var matches = months.filter(function (m) {
        return lc(m.slice(0, input.value.length)) === lc(input.value);
    });
    c.suggest(matches);
});
function lc (x) { return x.toLowerCase() }

methods

var c = auto(input, fn)

Create a new autocomplete instance c that wraps an input element and optionally sets up a keydown listener fn.

fn(c, ev) fires when there is new text input to deal with.

c.suggest(suggestions)

Auto-complete an array of suggestions. The first suggestion in the array is shadowed under the active text.

c.set(value)

Set the value for the input text and the shadow text.

install

With npm do:

npm install autocomplete-element

license

MIT

Keywords

FAQs

Last updated on 19 Jan 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc