So, I searched, but could not find the answer. It may be something trivial, but I just donβt see what causes it.
I use jQuery UI autocomplete, it displays json results. Therefore, I know that my JSON is valid. However, this does not filter anything. So I can enter a number and just show all the data. Any advice would be greatly appreciated!
I appreciate your time!
Here is my autocomplete code.
$.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 });
source share