|
1 | | -define(['libs/jquery.tinysort'], function () { |
| 1 | +define(['tinysort'], function (tinysort) { |
2 | 2 |
|
3 | 3 | /** |
4 | 4 | * MultipleSelect - an alternative to QuickSelect |
@@ -90,13 +90,21 @@ define(['libs/jquery.tinysort'], function () { |
90 | 90 | }, |
91 | 91 | sortInitial: function () { |
92 | 92 | this.findInitialOptions(); |
93 | | - this.initial.sort(this.compareElements); |
94 | | - this.initial.detach().appendTo(this.initialNode); |
| 93 | + const initialOptions = Array.from(this.initialNode[0].options); |
| 94 | + const sortedOptions = tinysort(initialOptions, {selector: null, order: 'asc', natural: true}); |
| 95 | + this.initialNode.empty(); |
| 96 | + for (const option of sortedOptions) { |
| 97 | + this.initialNode[0].appendChild(option); |
| 98 | + } |
95 | 99 | }, |
96 | 100 | sortChoices: function () { |
97 | 101 | this.findChoiceOptions(); |
98 | | - this.choices.sort(this.compareElements); |
99 | | - this.choices.detach().appendTo(this.choiceNode); |
| 102 | + const choiceOptions = Array.from(this.choiceNode[0].options); |
| 103 | + const sortedOptions = tinysort(choiceOptions, {selector: null, order: 'asc', natural: true}); |
| 104 | + this.choiceNode.empty(); |
| 105 | + for (const option of sortedOptions) { |
| 106 | + this.choiceNode[0].appendChild(option); |
| 107 | + } |
100 | 108 | }, |
101 | 109 | addSubmitHandler: function () { |
102 | 110 | /* Selects all elements in the initial node so that it is |
|
0 commit comments