GithubHelp home page GithubHelp logo

livesearch's Introduction

LiveSearch

Simple live search tool.

For jQuery variant, see v1

Quick usage with CDN

<srcipt src="https://unpkg.com/livesearch/js/livesearch.min.js"><script>

See the usage part below for more options.

Installation

$ npm i livesearch

or with Yarn

$ yarn add livesearch

Usage

You can access the component in 2 ways:

  • node_modules/livesearch/js/livesearch.js <- uncompressed ES6 file
  • node_modules/livesearch/js/livesearch.min.js <- compressed ES5 file

Example usage

// ...
var livesearch = new LiveSearch('/url/where/to/search', document.getElementById('search-response-container'));

document.getElementById('search-input').addEventListener('keyup', function(e) {
    var value = this.value;
    var currentKey = e.which;

    livesearch.search(value, currentKey);
});
// ...

Important notes

You can add url and container parameters as 3rd and 4th parameters for the search function to override the default ones.

You can skip the constructor parameters if you want to add them only for the search function.

You can skip the 2nd (currentKey) parameter if you want your LiveSearch to run for every single keypress (no disallowed keys).

You can change the allowed keys:

livesearch.allowedKeys = [8, 32, 46]; // these are the default ones: backspace, space and delete

You can change the delay between the keypress and the search with the typeDelay attribute the same way.

livesearch's People

Contributors

sbolch avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

martinsvacina

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.