Skip to content

handleLiveSearch() error #7

@lucianobapo

Description

@lucianobapo

resources/assets/administrator/js/theme.js line 209
function with error handleLiveSearch()

Error: $(...).selectize is not a function

static handleLiveSearch() {
        $('[data-type="livesearch"]').selectize({
            valueField: 'id',
            labelField: 'name',
            searchField: ['name'],
            create: false,
            loadThrottle: 500,
            maxOptions: 100,
            load: function(query, callback) {
                if (!query.length >= 3) return callback();

                let selectize = $($(this)[0].$input);

                let baseUrl = selectize.data('url');
                let url = baseUrl + (-1 === baseUrl.indexOf('?') ? '?' : '&');
                url += 'query=' + query;

                $.ajax({
                    url: url,
                    type: 'GET',
                    error: callback,
                    success: function(res) {
                        if (!res.hasOwnProperty('items')) {
                            console.error(
                                'Livesearch response should have "items" collection. ' +
                                'Each element in collection must have at least 2 keys: "id" and "name"',
                            );

                            return false;
                        }

                        return callback(res.items);
                    },
                });
            },
        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions