JQuery UI Autocomplete Does Not Filter Data

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 }); 
+6
source share
2 answers

Filtering should be done on the server side, based on the "Term" parameter. Check what data your server returns using Firebug or Chrome (F12) development tools and make sure that it depends on the "term" parameter.

+2
source

this article explains that jQuery UI autocomplete component dude :)

JQuery UI Autocomplete

0
source

Source: https://habr.com/ru/post/905871/


All Articles