[英]Choices.js: How to display selected choices in original order?
By default, the selected choices are displayed in the field in the order they were selected.默认情况下,选定的选项按它们被选择的顺序显示在字段中。 However, I would like them to always show in their hard-coded order.但是,我希望它们始终以硬编码顺序显示。
Basically, Choices.js provides the shouldSort
option to determine if the list of choices shows in its original order or in alphabetical order.基本上,Choices.js提供shouldSort
选项以确定是否选择节目列表中的原有顺序或按字母顺序排列。 But I would like the selected choices to have the same kind of option.但我希望所选的选项具有相同的选项。
Is this possible?这可能吗?
I also was looking for this solution, if anyone else needs it in the future.如果将来有人需要它,我也在寻找这个解决方案。
shouldSort: false
This will disable the sorting feature of choices js and display it in the original order.这将禁用选择 js 的排序功能并以原始顺序显示它。
Example:例子:
const selectColors = document.querySelector('.js-colors');
new Choices(selectColors, {
searchEnabled: false,
itemSelectText: '',
shouldSort: false,
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.