npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flexcomplete

v1.0.6

Published

A flexible autocomplete plugin for jQuery

Downloads

10

Readme

view on npm view on github npm npm module downloads

Flexcomplete

A flexible autocomplete plugin for jQuery. It works with online and offline data.

Getting Started

Download the production version or the development version.

In your web page:

<script src="jquery.js"></script>
<script src="dist/flexcomplete.min.js"></script>
<script>
$(function() {

  $('#myInput').flexcomplete({
        url: 'http://localhost:8080/search', // <-- your_search_url_here
        onSelect: function(value, input) {
            input.value = value;
            console.log('You selected the value:' + value);
        }
  }); 
});
</script>

API

search - search for a query searchQuery and shows the results

$('#myObject').flexcomplete('search', searchQuery);

close - close the results box

$('#myObject').flexcomplete('close');

select - select the resulted by index

$('#myObject').flexcomplete('select', index);

extend|options - config the Flexcomplete default options

// sets the default delay to 500ms
var settings = {
  delay: 500
};
$('#myObject').flexcomplete('extend', settings);
// or
$('#myObject').flexcomplete('options', settings);

destroy|unload - destroys the Flexcomplete instance

$('#myObject').flexcomplete('destroy');
// or
$('#myObject').flexcomplete('unload');

staticData - set the static data dynamically

var data = ['foo', 'bar', 'baz'];
$('#myObject').flexcomplete('staticData', data);

To change flexcomplete behaviour globally you must override the $.flexcomplete.options object. See below the option keys, their default values and their description.

// the parameter key with your search query
queryVar: "q"

// Http method
method: "GET"

// executed before flexcomplete sends your data to server, so you can process the input and change it anyway
processInput: function(value) { 
    return value;
}

// executed when the user selects an item from the list
onSelect: function(value, input) {
    input.value = value;
}

// if you want to process the input's value when the autoreplacing options is enabled override this function
getAutoreplacingInputValue: function(value) {
    return value;
}

// if you want to process the value that comes from the server to fulfill the items override this function
getLine: function(value) {
    return value;
}

// if you want to filter your data when staticDataSearch is enabled override this function
filter: function(arr, userSearch) {
    return arr; // you can filter arr here (check examples how to do it)
}

// delay between typing and sending the request to the server
delay: 100

// how many items are skipped on triggering an `page up` or `page down` when navigating the list
jump: 6

// how many chars are needed before send the first request to the server
startIn: 1

// select the result if there is only one item in the list
selectIfOneResult: false

// any extra parameters you want to send to the server
// can be an object or a function that returns an object
params: {} | function(instance){
    return {};
}

// any headers you want to send to the server
// can be an object or a function that returns an object
headers: {} | function(instance){
    return {};
}

// enable this option if you want to replace the input content when navigating through list items
autoReplacing: false

Examples

To see more examples of how to use Flexcomplete please check the demo directory.

Building

Developers can easily build Flexcomplete using NPM.

NPM

For the developers interested in building Flexcomplete:

npm install

Bower

For developers not interested in building the Flexcomplete library... use bower to install and use the Flexcomplete distribution files.

Change to your project's root directory.

# To get the latest stable version, use Bower from the command line.
bower install flexcomplete

CDN

CDN versions of Flexcomplete are available at:

With the GitCDN.xyz CDN, you will not need to download local copies of the distribution files. Instead simply reference the CDN urls to easily use those remote library files. This is especially useful when using online tools such as CodePen, Plunkr, or JSFiddle.

  <head>
  </head>
  <body>
    <!-- Flexcomplete available via GitCDN.xyz -->
    <script src="https://gitcdn.xyz/repo/thiagoh/flexcomplete/0.4.0/dist/jquery.flexcomplete.js"></script>
    <!-- Flexcomplete minified version available via GitCDN.xyz -->
    <script src="https://gitcdn.xyz/repo/thiagoh/flexcomplete/0.4.0/dist/jquery.flexcomplete.min.js"></script>
  </body>

Release History

  • 1.0.0 release
  • 0.4.0 beta release
  • 0.1.0 first release