Skip to content

na-2n/Compleet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy