Giter Club home page Giter Club logo

bootstrap-multiselectsplitter's Introduction

bootstrap-multiselectsplitter

Transforms a <select> containing one or more <optgroup> in two chained <select>.

This script is better version of bootstrap-selectsplitter, for multi select with more script options. If you want to select more options, you must hold CTRL key. (default select behaviour)

This:

image1

Becomes this:

image2

Dependencies

  • boostrap CSS > 3.0
  • jquery > 1.9.1
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

Installation

bower install bootstrap-multiselectsplitter

Usage

Create a <select> with at least one <optgroup>.

Each <option> of your <select> must have a unique value.

<select multiple="multiple">
  <optgroup label="Category 1">
    <option value="1">Choice 1</option>
    <option value="2">Choice 2</option>
    <option value="3">Choice 3</option>
    <option value="4">Choice 4</option>
  </optgroup>
  <optgroup label="Category 2">
    <option value="5">Choice 5</option>
    <option value="6">Choice 6</option>
    <option value="7">Choice 7</option>
    <option value="8">Choice 8</option>
  </optgroup>
  <optgroup label="Category 3">
    <option value="9">Choice 9</option>
    <option value="10">Choice 10</option>
    <option value="11">Choice 11</option>
    <option value="12">Choice 12</option>
  </optgroup>
</select>
$('select').multiselectsplitter();
$('select').multiselectsplitter('enable');
$('select').multiselectsplitter('disable');
$('select').multiselectsplitter('destroy');

Examples

Online demo

Options

  • selectSize - define size of new selects ... when null, automatically setted by longest option count DEFAULT: null
  • maxSelectSize - define max size of new selects DEFAULT: null
  • clearOnFirstChange - when true, second select will be cleared when the first changes DEFAULT: false
  • onlySameGroup - when true, only options from one optGroup can be selected (option works only for multiselect) DEFAULT: false
  • groupCounter - when true, there will be added counter of how many options are selected (option works only for multiselect) DEFAULT: false
  • maximumSelected - define how many options can be selected. Can be integer or function with arguments ($firstSelect, $secondSelect) that return integer. (option works only for multiselect) DEFAULT: null
  • afterInitialize - function with 2 arguments ($firstSelect, $secondSelect) - called after initialization DEFAULT: null
  • maximumAlert - function called when selected more than 'maximumSelected' options ... DEFAULT: function (maximumSelected) { alert("Only " + maximumSelected + " values can be selected"); }
  • createFirstSelect - function for creating option in first select DEFAULT: function (label, $originalSelect) { return '<option>' + label + '</option>'; }
  • createSecondSelect - function for creating option in second select DEFAULT: function (label, $firstSelect) { return '<option>' + label + '</option>'; }
  • template - template for new selects DEFAULT: <div class="row" data-multiselectsplitter-wrapper-selector><div class="col-xs-12 col-sm-6"><select class="form-control" data-multiselectsplitter-firstselect-selector></select></div><div class="col-xs-12 col-sm-6"><select class="form-control" data-multiselectsplitter-secondselect-selector></select></div></div>

Changes

1.0.1 - added functions for disabling/enabling

1.0.0 - release

Copyright and license

Copyright (C) 2016 Ing. Matúš Ferko

Licensed under the MIT license.

bootstrap-multiselectsplitter's People

Contributors

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