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

Commit

Permalink
Add sortable option
Browse files Browse the repository at this point in the history
  • Loading branch information
homerjam committed Mar 26, 2014
1 parent 4469fd7 commit 6f09293
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6f09293

Please sign in to comment.