From 6f092930181c9833be3a87391b1a4d7b71d376e7 Mon Sep 17 00:00:00 2001 From: homerjam Date: Wed, 26 Mar 2014 08:47:15 +0000 Subject: [PATCH] Add sortable option --- src/select2.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/select2.js b/src/select2.js index 828032d..8214f82 100644 --- a/src/select2.js +++ b/src/select2.js @@ -102,6 +102,18 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec } elm.select2( 'data', convertToSelect2Model(viewValue)); + if (opts.sortable) { + elm.select2("container").find("ul.select2-choices").sortable({ + containment: 'parent', + start: function () { + elm.select2("onSortStart"); + }, + update: function () { + elm.select2("onSortEnd"); + elm.trigger('change'); + } + }); + } } else { if (angular.isObject(controller.$viewValue)) { elm.select2('data', controller.$viewValue);