GithubHelp home page GithubHelp logo

feliixx / select-multiple-big Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 4.0 11 KB

blazing-fast dropdown selector with live search to handle very large datasets

License: The Unlicense

JavaScript 100.00%
dropdown searchbar bootstrap jquery jquery-plugin fast

select-multiple-big's Introduction

select-multiple-big

a small JS plugin build on top of JQuery and bootstrap to create a dropdown selector with live search that can handle very large number of items with 0 display latency.

a live demo is available here ( with 100 000 items) : live demo

How to use the plugin

first, add bootstrap and JQuery js and css :

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
...
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

then add an HTML div element somewhere in the DOM like this :

<div id="select"></div>

finally, instantiate the dropdown with some js code :

$('#select').selectmultiple({
  text: 'items',                          // title when no items selected 
  data: [ "item1", "item2", "item3" ],    // an array of string containing the list of item to display in the dropdown
  width: 200,                             // the dropdown width
  placeholder: 'items'                    // text-search placeholder 
});

when the user select some items, a custom event is fired : multiple_select_change you can catch it by adding a listener like this :

$('#select').on('multiple_select_change', function() {
  // do some stuff 
});

Custom methods

get the number of selected items:

var count = $('#select').selectmultiple('count')
// count = 3

get the selected items:

var values =  $('#select').selectmultiple('value')
// values = [ "item1", "item11", "item111" ]

get all availables item in the dropdown:

var options = $('#select').selectmultiple('option')
// options = [ "item1", "item2", "item3", ... ]

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.