在“选择的"中键入2个字符后开始搜索 [英] Start search after 2 character typed in Chosen drop down

查看:67
本文介绍了在“选择的"中键入2个字符后开始搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选择的下拉插件中,在选择的下拉菜单中键入2个字符后开始搜索

In Chosen drop down plugin, a search is started after 2 characters are typed in chosen drop down.

我需要直到在搜索框中输入至少两个字符后才能开始搜索.

I need the search to not start until after inputing at least two characters in the search box.

有人可以建议如何做吗?

Can any one suggest how to do this?

推荐答案

AbstractChosen中选择的JS中,我做了一个小小的改动以开始搜索第三个字符之后,这不是最好的选择,但可以工作.在 searchText = this.get_search_text(); 行之后的prototype.winnow_results 函数添加以下代码: if(searchText!="&& searchText.length< 3)返回; .记住要更改< 3按您自己的大小.

I did a small change to start to search after the third character, is not the best option but works, in the chosen JS in the AbstractChosen.prototype.winnow_results function after the line searchText = this.get_search_text(); add the following code: if (searchText != "" && searchText.length < 3) return;. Remember to change the < 3 by your own size.

希望对您有帮助

请参阅下面的代码部分:

See part of the code below:

AbstractChosen.prototype.winnow_results = function() {
  var escapedSearchText, option, regex, regexAnchor, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
  this.no_results_clear();
  results = 0;
  searchText = this.get_search_text();
  if (searchText != "" && searchText.length < 3) return;
  escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");

这篇关于在“选择的"中键入2个字符后开始搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆