如何禁用 Choices.js 中的项目按字母顺序自动排序?
How to disable the automatic sorting of items alphabetically in Choices.js?
我有以下数组:
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
函数,但它只指定了排序方法。
看来您需要 属性 shouldSort
。 readme 有详细信息。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project'
shouldSort: false,
})
默认排序是正确的,但您可以传递另一个 属性 shouldSort。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project',
shouldSort: false
})
我有以下数组:
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
函数,但它只指定了排序方法。
看来您需要 属性 shouldSort
。 readme 有详细信息。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project'
shouldSort: false,
})
默认排序是正确的,但您可以传递另一个 属性 shouldSort。
const $projectDropdown = new Choices($this[0], {
placeholder: true,
placeholderValue: 'Select a project',
shouldSort: false
})