From f9e015267edfe8a3f9a1c8f22be79398af1af15f Mon Sep 17 00:00:00 2001 From: Jarek Jakubowski Date: Wed, 5 Sep 2018 15:32:18 +0200 Subject: [PATCH] Fix sorting --- web/ajax-multict-select-field.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/ajax-multict-select-field.js b/web/ajax-multict-select-field.js index 3aadd0e..8e57fae 100644 --- a/web/ajax-multict-select-field.js +++ b/web/ajax-multict-select-field.js @@ -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); }); } });