ags*_*ver 6 jquery json filtering jquery-ui-autocomplete
所以我搜索但找不到答案.这可能是微不足道的,但我无法看到导致这种情况的原因.
我正在使用jQuery UI Autocomplete,它显示了json结果.所以我知道我的JSON是有效的.但是,它没有过滤任何东西.所以我可以输入一个数字,它只显示所有数据.任何提示将非常感谢!
我很感激你的时间!
这是我的自动完成代码.
$.widget('custom.catcomplete', $.ui.autocomplete, {
_renderMenu: function(ul, items) {
var self = this,
currentCategory = '';
$.each(items, function(index, item) {
if (item.category != currentCategory) {
ul.append('<li class="ui-autocomplete-category">' + item.category + '</li>');
currentCategory = item.category;
}
self._renderItem(ul, item);
});
}
});
$('#category').catcomplete({
source: function(request, response) {
$.ajax({
url: '/wp-content/plugins/pagelines-sections/searchbar/products.json',
dataType: 'json',
data: {
term: request.term
},
cache: true,
success: function(data) {
response($.map(data.products, function(item) {
return {
category: item.category,
label: item.label,
value: item.value
};
}));
}
});
},
minLength: 1
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3148 次 |
| 最近记录: |