Revision 68879d96
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
js/jquery.multiselect2side.js | ||
---|---|---|
22 | 22 |
labelSort: 'Sort', |
23 | 23 |
labelsx: 'Available', |
24 | 24 |
labeldx: 'Selected', |
25 |
maxSelected: -1 |
|
25 |
maxSelected: -1, |
|
26 |
leftSel: null, |
|
27 |
rightSel: null, |
|
28 |
|
|
29 |
sortOptions: function() { |
|
30 |
o.leftSel.sortOptions(); |
|
31 |
o.rightSel.sortOptions(); |
|
32 |
} |
|
26 | 33 |
}, o); |
27 | 34 |
|
28 | 35 |
return this.each(function () { |
... | ... | |
93 | 100 |
var rightSel = (o.selectedPosition == 'right') ? allSel.eq(1) : allSel.eq(0); |
94 | 101 |
// HEIGHT DIV |
95 | 102 |
var heightDiv = $(".ms2side__select").eq(0).height(); |
103 |
o.leftSel = leftSel; |
|
104 |
o.rightSel = rightSel; |
|
96 | 105 |
|
97 | 106 |
// CENTER MOVE OPTIONS AND UPDOWN OPTIONS |
98 | 107 |
$(this).next().find('.ms2side__options, .ms2side__updown').each(function(){ |
... | ... | |
152 | 161 |
rightSel.find("option").each(function(idx, option) { |
153 | 162 |
$('<input type="hidden"/>').attr("name", hiddenName).attr("value", $(option).attr("value")).appendTo(hiddenCont); |
154 | 163 |
}); |
155 |
|
|
156 |
leftSel.sortOptions(); |
|
157 |
rightSel.sortOptions(); |
|
158 | 164 |
}); |
159 | 165 |
|
160 | 166 |
// DOUBLE CLICK ON LEFT SELECT OPTION |
... | ... | |
167 | 173 |
} |
168 | 174 |
}); |
169 | 175 |
$(this).trigger('change'); |
176 |
o.sortOptions(); |
|
170 | 177 |
}); |
171 | 178 |
|
172 | 179 |
// DOUBLE CLICK ON RIGHT SELECT OPTION |
... | ... | |
176 | 183 |
el.find("[value=" + $(selected).val() + "]").attr("selected", false).remove().appendTo(el); |
177 | 184 |
}); |
178 | 185 |
$(this).trigger('change'); |
186 |
o.sortOptions(); |
|
179 | 187 |
}); |
180 | 188 |
|
181 | 189 |
// CLICK ON OPTION |
... | ... | |
186 | 194 |
$(this).remove().appendTo(rightSel); |
187 | 195 |
el.find("[value=" + $(selected).val() + "]").attr("selected", true).remove().appendTo(el); |
188 | 196 |
}); |
197 |
o.sortOptions(); |
|
189 | 198 |
|
190 | 199 |
} else if ($(this).hasClass("AddAll")) { // ALL SELECTED |
191 | 200 |
leftSel.children().appendTo(rightSel); |
192 | 201 |
leftSel.children().remove(); |
193 | 202 |
el.find('option').attr("selected", true); |
194 | 203 |
// el.children().attr("selected", true); -- PROBLEM WITH OPTGROUP |
204 |
o.sortOptions(); |
|
195 | 205 |
|
196 | 206 |
} else if ($(this).hasClass("RemoveOne")) { |
197 | 207 |
rightSel.find("option:selected").each(function(i, selected){ |
198 | 208 |
$(this).remove().appendTo(leftSel); |
199 | 209 |
el.find("[value=" + $(selected).val() + "]").attr("selected", false).remove().appendTo(el); |
200 | 210 |
}); |
211 |
o.sortOptions(); |
|
201 | 212 |
|
202 | 213 |
} else if ($(this).hasClass("RemoveAll")) { // ALL REMOVED |
203 | 214 |
rightSel.children().appendTo(leftSel); |
204 | 215 |
rightSel.children().remove(); |
205 | 216 |
el.find('option').attr("selected", false); |
206 | 217 |
//el.children().attr("selected", false); -- PROBLEM WITH OPTGROUP |
218 |
o.sortOptions(); |
|
207 | 219 |
} |
208 | 220 |
} |
209 | 221 |
|
... | ... | |
284 | 296 |
|
285 | 297 |
// UPDATE BUTTON ON START |
286 | 298 |
leftSel.trigger('change'); |
299 |
o.sortOptions(); |
|
287 | 300 |
// SHOW WHEN ALL READY |
288 | 301 |
$(this).next().show(); |
289 | 302 |
}); |
Auch abrufbar als: Unified diff
Nicht im onchange sortieren
Dadurch wurden Selektionen zurückgesetzt, was Multi-Select verhindert
hat.