jQuery UI Autocomplete Not Filtering Data

三世轮回 提交于 2019-12-08 21:59:35

问题


So I searched but could not find the answer. This could be something trivial however I just can't see what is causing this.

I'm using the jQuery UI Autocomplete, it's displaying the json results. So I know my JSON is valid. However, it's not filtering anything. So I can enter a number and it just show's all of the data. Any tips would be very much 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
   });

回答1:


Filtering must be performed server-side, based on "Term" parameter. Check, what data your server returns with Firebug or Chrome developer tools (F12), and ensure, that it depends on "term" parameter.




回答2:


in this article a explain completed about JQuery UI Auto-complete component dude :)

Jquery UI AutoComplete



来源:https://stackoverflow.com/questions/8843496/jquery-ui-autocomplete-not-filtering-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!