Browse Source

[Dropdown] Add option for natural sorting

Fixes #4775

The in 2.3.1 added `ignoreCase` setting for the dropdown only applies to the selection additions, with no 'natural' sorting option for the dropdown menu.

`sortNatural` defaults to `true` when `sortSelect` is turned on.
pull/6412/head
Wiethoofd 7 years ago
committed by GitHub
parent
commit
6a7815e8cc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions
  1. 11
      src/definitions/modules/dropdown.js

11
src/definitions/modules/dropdown.js

@ -1865,7 +1865,15 @@ $.fn.dropdown = function(parameters) {
}
if(settings.sortSelect) {
select.values.sort(function(a, b) {
return (a.name > b.name)
var
aName = a.name,
bName = b.name
;
if(settings.sortNatural) {
aName = aName.toLowerCase();
bName = bName.toLowerCase();
}
return (aName > bName)
? 1
: -1
;
@ -3696,6 +3704,7 @@ $.fn.dropdown.settings = {
placeholder : 'auto', // whether to convert blank <select> values to placeholder text
preserveHTML : true, // preserve html when selecting value
sortSelect : false, // sort selection on init
sortNatural : true, // use natural sorting when reordering values
forceSelection : true, // force a choice on blur with search selection

Loading…
Cancel
Save