Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 2781639

Browse files
committed
Merge pull request #181 from homerjam/sortable
Add sortable option
2 parents 5482d8f + 6f09293 commit 2781639

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/select2.js

+12
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
105105
}
106106
elm.select2(
107107
'data', convertToSelect2Model(viewValue));
108+
if (opts.sortable) {
109+
elm.select2("container").find("ul.select2-choices").sortable({
110+
containment: 'parent',
111+
start: function () {
112+
elm.select2("onSortStart");
113+
},
114+
update: function () {
115+
elm.select2("onSortEnd");
116+
elm.trigger('change');
117+
}
118+
});
119+
}
108120
} else {
109121
if (angular.isObject(controller.$viewValue)) {
110122
elm.select2('data', controller.$viewValue);

0 commit comments

Comments
 (0)