selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

Items not reaching render after success of load function

Open rajuponnala opened this issue 11 years ago • 5 comments

This is my code: $("#my_search_box").selectize({ "onChange": refreshAdminMailSuggest, "valueField": "title", "labelField": "title", "searchField": "title", "options": [], "create": false,

        "render": {
            option: function(item, escape) {

                console.log(item);

                return (
                        "<div>" +
                            "<span class='title'>" +
                                "<span class='name'>" + escape(item.title) + "</span>" +
                            "</span>" +
                        "</div>"
                    );
            }
        },
        load: function(query, callback) {
            if (query.length < 2) {
                return callback();
            }
            $.ajax({
                "url": "/maintain/mailbox/admin-mail-suggest",
                "type": "POST",
                "data": {
                    "item": "admin_mail_box",
                    "str": query
                },
                "dataType": "json",
                error: function() {
                    callback();
                },
                success: function(res) { 

                    console.log(res);
                    callback(res);
                }
            });
        },

    });

And i am getting data as below after the success of load function: { "title" : "maruthi" }

However, the console.log(item) is not printing anything.

I just stumbled upon #200 and #509 . But that doesn't seem to be the same issue as this. @brianreavis : can you please provide me the quick solution? as this is urgent for me..

rajuponnala avatar Aug 04 '15 02:08 rajuponnala

Is anyone out there who can provide the solution for this??

rajuponnala avatar Aug 04 '15 06:08 rajuponnala

Can we wait for the answer and rely on this?! please reply. It is urgent for me..

rajuponnala avatar Aug 04 '15 06:08 rajuponnala

Selectize expects an array of options, not a single item.

brianreavis avatar Aug 04 '15 06:08 brianreavis

Thanks @brianreavis . That worked. And one more question.. When an option is selected, how to get the value of the group to which that selected option belongs to?

rajuponnala avatar Aug 06 '15 04:08 rajuponnala

closing stale issues older than one year. If this issue was closed in error please message the maintainers. All issues must include a proper title, description, and examples.

risadams avatar Nov 11 '20 18:11 risadams