View on GitHub

Select2.sortable

Combines select2 and html5sortable for sorted multi-selectlist awesomeness!

Download this project as a .zip file Download this project as a tar.gz file

Installing


Include the dependencies: jquery, select2, html5sortable

Include the following files into your <head>:


select2.sortable.js

select2.sortable.css






Usage

Suppose you got a multiselect like this one (view html in inspector):



Use this code:

$('.select2.sortable').select2Sortable();

To get searchable, sortable awesomeness:



Set initial order


Set initially selected options as usual and set the initial order with data-order-attribute:

<select multiple data-order="3,1,5"></select>

With options 1,3,5 selected, it will look like:


You can also change the order with javascript, programatically:

$('.select2.sortable').select2Sortable([5,3,1]);