Typeahead 仅显示完全匹配。如何显示从远程 url. 返回的所有数据?
Typeahead only showing the exact match. How can I show all the data that is returned from remote url.?
我遇到一个问题,我想执行一个搜索,如果您键入带有双引号 ("") 的字符串,它也必须有效。
示例:apple 和 "apple" 都必须 return 相同的结果
当我调用后端时,对搜索查询的调用正在重新调整相同的东西,但是预先输入以某种方式过滤数据,并且在 "apple" 的情况下数据不会显示。
我已经尝试使用像 dropDownFilter 这样的过滤器,并通过将它们分配为 false 来进行过滤:
$('#searchInput').typeahead({ minLength: 1, order: "asc", delay: 500,
dynamic: true, groupMaxItem: 6, highlight: false,
hint: true, group: ["{{group}}, kind"],
dropdownFilter: false,
但是它不起作用,谁能给我一些建议。
任何帮助将不胜感激!
尝试提供您自己的匹配器函数。大致如下:
$('.typeahead').typeahead({source:myarray, matcher: function(item){
// the regular expression will (optionally) consider double-quotes
var reg = new RegExp('"?'+this.query+'"?');
if( item.match(reg) ){
return true;
}else{
return false;
}
}});
我遇到一个问题,我想执行一个搜索,如果您键入带有双引号 ("") 的字符串,它也必须有效。
示例:apple 和 "apple" 都必须 return 相同的结果
当我调用后端时,对搜索查询的调用正在重新调整相同的东西,但是预先输入以某种方式过滤数据,并且在 "apple" 的情况下数据不会显示。
我已经尝试使用像 dropDownFilter 这样的过滤器,并通过将它们分配为 false 来进行过滤:
$('#searchInput').typeahead({ minLength: 1, order: "asc", delay: 500,
dynamic: true, groupMaxItem: 6, highlight: false,
hint: true, group: ["{{group}}, kind"],
dropdownFilter: false,
但是它不起作用,谁能给我一些建议。
任何帮助将不胜感激!
尝试提供您自己的匹配器函数。大致如下:
$('.typeahead').typeahead({source:myarray, matcher: function(item){
// the regular expression will (optionally) consider double-quotes
var reg = new RegExp('"?'+this.query+'"?');
if( item.match(reg) ){
return true;
}else{
return false;
}
}});