用空格选择jQuery插件搜索

时间:2013-09-27 12:07:14

标签: javascript jquery user-interface

我对选择的jQuery plugin有疑问。当我尝试搜索其中包含空格的字符串时,即使它确实存在也没有结果。

例如: 如果我输入字符串“and barbu”,我什么也得不回来。但是当我写“antigua and barbu”时,我得到了结果。

我该怎么做才能解决这个空间问题?

1 个答案:

答案 0 :(得分:25)

在这里回答:Changing search behavior in jquery plugin Chosen 只需要添加

jQuery('select').chosen({search_contains:true}) ;

正如选项文档中提到的那样: http://harvesthq.github.io/chosen/options.html

search_contains false默认情况下,Chosen的搜索匹配从单词的开头开始。将此选项设置为true允许从单词中的任何位置开始匹配。这对于包含()s和[] s中的许多特殊字符或短语的选项特别有用。