Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compleet

Zero dependency JavaScript autocompletion library.

Why

Because there weren't any other libraries that did what I needed.

Usage

const input = document.querySelector("input#myinput");

input.compleet({
// OR
compleet(input, {
    // General options
    maxResults: 10, // max results, default is 5
    raw: false, // whether to use innerHTML or innerText to set autocomplete options, default is false (innerText)
    //   ^^^^^ DO NOT SET THIS TO TRUE IF YOU PROVIDE UNFILTERED USER TAGS, YOU HAVE BEEN WARNED

    // Tag source options
    source: function(term, resp) {
        const val = term.split(" ").pop(); // split the value by spaces
        const terms = getTermsFromSomewhere(); // get the terms from somewhere
        const matched = terms.filter(function(t) { return t.startsWith(val); }); // filter the terms

        resp(matched, val); // send the response
    },
    // OR
    tags: function(resp) {
        getTermsFromSomewhere(function(terms) { resp(terms); });
    }
});

Contributing

PRs are always welcome!

About

Zero dependency HTML input autocompletion library

Topics

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages