[英]How to remove filter criteria and display data on focus of a Text Input field when using Jquery Autocomplete feature
This is a program which is responsible to display autosuggestions . 这是一个负责显示自动建议的程序。
When i keep the focus inside the tags input field , it should display all the available data present inside the source , (i don't need any filter criteria ) 当我将焦点保持在标签输入字段内时,它应显示源内部存在的所有可用数据(我不需要任何过滤条件)
On focus of the text input field it should display all the data 在文本输入字段的焦点上,它应该显示所有数据
This is my jsfiddle 这是我的jsfiddle
http://jsfiddle.net/n30bku6v/1/ http://jsfiddle.net/n30bku6v/1/
$(document).on('focus', '#tags', function() {
$( "#tags" ).autocomplete({
source: availableTags
});
});
Could you please tell me how to do this 你能告诉我怎么做吗
I think first of all you should bring your autocomplete
initialization out of onFocus
callback, so it won't initialize on each focus event. 我认为首先您应该将
autocomplete
初始化从onFocus
回调中onFocus
,因此不会在每个焦点事件上进行初始化。
To achieve your desired behavior, you could use minLength
property and search
method, like this: 为了实现所需的行为,可以使用
minLength
属性和search
方法,如下所示:
$(function(){
$("#tags").autocomplete({
source: availableTags,
minLength: 0
});
$(document).on('focus', '#tags', function() {
$("#tags").autocomplete("search","");
});
});
Using minLength
we say to autocomplete to work even when there is no query, and search
method is used to trigger autocomplete with empty query. 我们说使用
minLength
可以使自动完成功能即使在没有查询的情况下也能正常工作,并且search
方法用于触发带有空查询的自动完成功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.