Skip to content

Commit

Permalink
Merge pull request #8 from JarJak/patch-3
Browse files Browse the repository at this point in the history
Fix saving order of selected options
  • Loading branch information
graham73may authored Dec 19, 2018
2 parents 5138639 + f9e0152 commit d0b86a8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions web/ajax-multict-select-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
$.fn.extend({
customSelect2Sortable : function () {
var $select = $(this);
var ul = $select.next('.select2-container').first('ul.select2-selection__rendered');
var $ul = $select.next('.select2-container').find('ul.select2-selection__rendered').first();

ul.sortable({
$ul.sortable({
items : 'li:not(.select2-search)',
tolerance : 'pointer',
stop : function () {
$($(ul).find('.select2-selection__choice').get().reverse()).each(function () {
$($ul.find('.select2-selection__choice').get().reverse()).each(function () {
var id = $(this).data('data').id;
var option = $(this).find('option[value="' + id + '"]')[0];
var option = $select.find('option[value="' + id + '"]')[0];

$(this).prepend(option);
$select.prepend(option);
});
}
});
Expand Down

0 comments on commit d0b86a8

Please sign in to comment.