简体   繁体   English

jQuery UI自动完成字母顺序

[英]jquery UI autocomplete alphabetical ordering

Please see the following default example 请参阅以下默认示例

http://jqueryui.com/autocomplete/ (default functionality) http://jqueryui.com/autocomplete/ (默认功能)

When you type Scala and Schema those results are almost all the way down to the bottom although I would expect them to be first as they both start by S. 当您输入Scala和Schema时,这些结果几乎一直都排到最底端,尽管我希望它们都以S开头,所以它们会排在第一位。

I think the reason is that it starts from the top of the list down checking to see if there are any Ss (Actionscript is the first entry in availableTags) and there is no default filtering. 我认为原因是它从列表的顶部开始向下检查是否有任何S(Actionscript是availableTags中的第一项)并且没有默认过滤。

If i was going to use something like cities and I limit the results to 10 and type "S" the first 10 results would not be cities that start by S but whatever contains s and is first in the list. 如果我要使用诸如city之类的东西,并且将结果限制为10并键入“ S”,则前10个结果将不是以S开头但包含s并且在列表中排在首位的城市。

Is there a way around this ? 有没有解决的办法 ?

Sample fiddle here 样本小提琴在这里

Question2: How can the current entry get highlighted on the displayed results? 问题2:如何在显示的结果上突出显示当前条目?

You could use the jquery plugin selectize.js. 您可以使用jquery插件selectize.js。 This is how you could do it : http://plnkr.co/edit/1zmretjQGXeVnh74IMRj 这是您的方法: http : //plnkr.co/edit/1zmretjQGXeVnh74IMRj

As you can see by typing "sc", scala and scheme come first, and are highlighted. 如您所见,通过键入“ sc”,scala和scheme排在最前面,并突出显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM