6

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
   });

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Jquery UI AutoComplete

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.