0
votes

Hi I am new to selectize plugin. I have changed code in github example (https://github.com/brianreavis/selectize.js/blob/master/examples/github.html) to fit for my application. When I write something in input field it searches from data base but does not show dropdown list. It shows list when I remove text in input field. And when I input text again the dropdown vanishes. What I am doing wrong?

$('#select-tag').selectize({
                valueField: 'name',
                labelField: 'name',
                searchField: 'name',
                options: [],
                create: false,
                render: {
                    option: function (item, escape) {
                        return '<div>' +
                            '<span class="title"><span class="name">' + escape(item.name) + '</span></span>' +
                            '<span class="description">' + escape(item.info) + '</span></div>';
                    }
                },
                score: function (search) {
                    var score = this.getScoreFunction(search);
                    return function (item) {
                        return score(item) * (1 + Math.min(item.watchers / 100, 1));
                    };
                },
                load: function (query, callback) {
                    if (!query.length) return callback();
                    $.ajax({
                        url: '/api/forum/SearchTags?s=' + encodeURIComponent(query),
                        type: 'POST',
                        error: function () {
                            callback();
                        },
                        success: function (res) {
                            console.log(res);
                            callback(res.slice(0, 10));
                        }
                    });
                }
            });
1

1 Answers

1
votes

Just removed lines below and it worked fine!

score: function (search) {
                    var score = this.getScoreFunction(search);
                    return function (item) {
                        return score(item) * (1 + Math.min(item.watchers / 100, 1));
                    };
                },