Giter VIP home page Giter VIP logo

typeahead-multiselect's Introduction

Typeahead-multiselect: a tiny extension to twitter typeahead to allow multiple selections

Typeahead-multiselect extends the current functionality of Twitter Typeahead to allow multiple selections.

Usage

You can use Typeahead-multiselect using the same signature as Typeahead. See it live

<div id="typeaheadmulti">
  <input class="typeahead" type="text" placeholder="Search Languages">
</div>
var language = new Bloodhound({
  datumTokenizer: Bloodhound.tokenizers.whitespace,
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  local: ["English", "Arabic", "Japanese"]
});

$('#typeaheadmulti .typeahead').typeaheadmulti({
  hint: true,
  highlight: true,
  minLength: 1
},
{
  name: 'language',
  source: language
});

Options

All typeahead.js options are valid. In addition:

selectionsContainer: A Jquery-valid selector for the container where the selections will be added.

Dataset templates:

Templates should either be a string of a function that returns a string to be rendered. Handlebar temaplates are not supported.

emptySelection: Will be used to fill the container when no selections are selected. selection: Should be a function that takes the selected object and returns a html string.

Events

selectionAdded and selectionRemoved are fired after a selection is added or removed from the selection container.

Styling

You can use the styles accompanied with the package typeahead-multiselect.css.min, which provides styling for the suggestion container. Selection container and selections are classed as list-group and list-group-item for bootrap compatiblity. If you want to use Boostrap for styling, make sure to include typeaheadjs.css.

Limitations

These are the current limitations for typeaheadmulti. All these limitations can be easily supported (the souce code is marked with TODOs). Contributions through pull requests all very welcome.

  • No support for multiple datasets.
  • Setting the selections programmatically by $.typehead('val', someVal)

License

Licensed under the MIT License.

typeahead-multiselect's People

Contributors

ahmohamed avatar

Watchers

James Cloos 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.