devbridge / jQuery-Autocomplete

Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields
https://www.devbridge.com/sourcery/components/jquery-autocomplete/
Other
3.56k stars 1.66k forks source link

TypeError: Cannot read property 'query' of undefined #703

Closed d00nn1 closed 6 years ago

d00nn1 commented 6 years ago

Hello everyone. I have this problem on the autocomplete I've looked for everywher but found nothing in google and somthing like this sory my English is not so good the problem com at this point

// Setup jQuery ajax mock:
$.mockjax({
    url: '*',
    responseTime: 2000,
    response: function (settings) {
        var query = settings.data.query,

//TypeError: Cannot read property 'query' of undefined

            queryLowerCase = query.toLowerCase(),
            re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi'),
            suggestions = $.grep(countriesArray, function (country) {
                 // return country.value.toLowerCase().indexOf(queryLowerCase) === 0;
                return re.test(country.value);
            }),
            response = {
                query: query,
                suggestions: suggestions
            };

        this.responseText = JSON.stringify(response);
    }
});

when sombody can help me thx a loot have nice day

tkirda commented 6 years ago

It is related to mocking library. This just states that settings.data value is undefined. This is only for testing purposes, you don't need to use mockjax with this plugin.