I have the following array:
options = [
"Asset Management & Investment Funds",
"Financial Institutions",
"Life Sciences",
"TMT",
"Other"
]
Choices.js by default sorts it alphabetically, and Other
ends up before TMT
which is jarring for the user.
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project'
})
I tried look into the sortFilter
function, but it only specifies the method of sorting.
It looks like you need the property shouldSort
. The readme has details.
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project'
shouldSort: false,
})
Default sorting is true but you can pass another property shouldSort.
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project',
shouldSort: false
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.