Giter Site home page Giter Site logo

cdohotaru / autocomplt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fischer-l/autocomplt

0.0 2.0 0.0 381 KB

Auto-generates the autocomplete list when user inputs some text in the <input> element.

License: MIT License

JavaScript 89.76% HTML 8.30% CSS 1.94%

autocomplt's Introduction

autoComplt

What is autoComplt ?

The autoComplt is written in Javascript and lightweight and simple to use. It auto-generates the autocomplete list when user inputs some text in the <input> element.

Try it here => http://fischer-l.github.io/autoComplt/

No need of any extra lib/framework

The autoComplt has no dependencies on other libs or frameworks.

How to use

== Load the script ==

Load the autoComplt js script into your document. After loading, there would be one global object called autoComplt. Use that global autoComplt object to enable the autocomplete feature on the desired <input> element.

== Example ==

Suppose the HTML:

<input name="name" type="text"></input>

Call autoComplt.enable to enable the autocompelte feature on the <input> element above as below:

var input = document.querySelector("input[name=name]");
autoComplt.enable(input, {
    // the hintsFetcher is your customized function which searchs the proper autocomplete hints based on the user's input value.
    hintsFetcher : function (v, openList) {
        var hints = [],
            names = [ "Masahiro Tanaka", "Darvish", "Daisuke Matsuzaka" ];
        
        for (var i = 0; i < names.length; i++) {
            if (names[i].indexOf(v) >= 0) {
                hints.push(names[i]);
            }
        }
        
        openList(hints);
    }
});

After running the codes here, the autocomplete list will appear to give the hints for users.

Configuration and styles

The <input> element which is enabled with the autocomplete feature would carrys one property named "autoComplt". Use that property's input.autoComplt.config method to config the autocomplete features and input.autoComplt.setStyles to change the UI styles. There are more public APIs for use, please refer to the autoComplt.js.

autocomplt's People

Contributors

fischer-l avatar gansbrest avatar

Watchers

James Cloos avatar Constantin Dohotaru avatar

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.