[英]jquery-ui auto-complete issue
I'm using the jQuery auto-complete, but I notice a strange issue that is happening in my input. 我正在使用jQuery自动完成功能,但是我发现输入中发生了一个奇怪的问题。 For example, in the example below:
例如,在下面的示例中:
$(function() {
var data = var data = [
{
"label": "12 12 North",
"value": "12 North",
"country_code": "IN",
"name": "12 North",
"code_airline": 12
},
...];
$('#sample-01').autocomplete({
maxShowItems: 5,
minLength:2,
source: data
});
});
I'm getting an array of objects that gives me some information regarding, in my case, airline companies. 我得到了一系列对象,这些对象为我提供了有关航空公司的一些信息。 If I start to search for the first characters of the airline company it gives me the correct label.
如果我开始搜索航空公司的首字母,它将给我正确的标签。
But then when I try to replace the data variable with the URL source, to be like: 但是,当我尝试用URL源替换数据变量时,就像这样:
$('#sample-01').autocomplete({
maxShowItems: 5,
minLength:2,
source: "http://www.json-generator.com/api/json/get/cqycMlSXci?indent=2"
});
It is not giving me the correct label/company name, as if the autocomplete stops filtering the correct data. 它没有为我提供正确的标签/公司名称,就像自动完成功能停止过滤正确的数据一样。 What is wrong with my code?
我的代码有什么问题?
String : When a string is used (...) The Autocomplete plugin does not filter the results....
字符串 :使用字符串时(...)自动完成插件不会过滤结果。
Try loading json data first, then populate autocomplete plugin. 尝试先加载json数据,然后填充自动完成插件。 For example:
例如:
$(function(){
var json = $.getJSON("http://www.json-generator.com/api/json/get/cqycMlSXci?indent=2");
json.done(function(data){
$('#sample-01').autocomplete({
maxShowItems: 5,
minLength:2,
source: data
});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.