我有以下数组:
options = [
"Asset Management & Investment Funds",
"Financial Institutions",
"Life Sciences",
"TMT",
"Other"
]
Choices.js默认情况下按字母顺序对其进行排序,并且Other
以TMT
结尾,这会给用户带来麻烦。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project'
})
我尝试研究sortFilter
函数,但它仅指定排序方法。
答案 0 :(得分:2)
您似乎需要属性shouldSort
。 readme有详细信息。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project'
shouldSort: false,
})
答案 1 :(得分:0)
默认排序为true,但是您可以传递另一个属性shouldSort。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project',
shouldSort: false
})