Giter VIP home page Giter VIP logo

zerocomplete's Introduction

Zerocomplete



Usage:

$('input').zerocomplete(options)

Here's a quick rundown of what options can contain:

Name type default description
source array, string [ ] The data source to query against. If this is a string then it's assumed to be a url to send the query to in the term get param. If it's an array, it can be an array of strings or an array of objects.
delay number 300 The amount of time to wait after the keypress before the ajax call
display function, string label When choosing from an array of objects, we need to know which property of the object to display in the dropdown (You don't want to display [object Object] for each item)
select function (nothing) The callback that gets called when the user selects an item from the dropdown or blurs the input when they don't choose an item from the list. You can also bind to the element's zerocompleteselect event
getPath function return res.data When using ajax as the source, this is the callback that will take the response object and get the source data, defaults to: `function(res) { return res.data
get function jQuery.get This is the function that does the ajax call, you can override it to send a xsrf token or to do some other logic, the term is the context and it passes the url and callback to run with the response passed in. eg
function (url, cb) {
 $.post(url, {some: 'data'}, function(res) {
  cb(res);
 });
}
response function (nothing) This function is called after an ajax request completes but before the items are rendered, this gets passed the array and should return an array
highlighter function typeahead func You can override the default behavior or way the the matched text is bolded. Useful for displaying complex views
cache object, false jQuery.cache.ajax By default all ajax calls are cached to jQuery.cache.ajax, you can set this to another object, or turn it off by setting it to false
search function (nothing) Callback that gets fired before a dropdown is displayed, return false to cancel

Note that all standard typeahead options (except source) get passed in with the typeahead invocation so all typeahead options should also work


Released under the MIT license

zerocomplete's People

Contributors

kolodny avatar

Stargazers

Michael Scott Hertzberg avatar tricarte avatar Jérôme Foray avatar  avatar

Watchers

 avatar  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.