Selectize.js: Loading Remote data , callback gets not called?

Created on 27 Jan 2014  路  8Comments  路  Source: selectize/selectize.js

Hello,
I am trying to modify the github repo example to be able to use it with my own service.

My service returns a data structure like this
(this is NOT the service i use, its just a dummy to reveal the data structure):
http://marcwensauer.de/public/dummy.json

Thats how the example result looks like:
https://api.github.com/legacy/repos/search/test

But when I call I can log the array but the callback gets never called:
http://i.imgur.com/Drf6VNh.png
I get no errors tho !

Result is that:

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

is never invoked, and therefore nothing is rendered.

Is something wrong with my data structure ?

Any idea why ? please

question

All 8 comments

Even I have the same problem, Guys Pls look into it.

You need to post your code if you want help.

Hi,
I am trying to use Remote Source having my own api built, Here is the code.

Here i am calling JSON data as api,

'http://apiurlgoeshere/getresponse/',

this API contains the json data.

Problem -
this API is successfully loading in console but whenever i am trying to get data in select box, but unfortunately its not displaying.
Pls help, Thanks a lot.

My code is here.

   JS Code
   ------------
            $('#select-app').selectize({
                valueField: 'title',
                labelField: 'title',
                searchField: 'title',
                options: [],
                create: false,
                render: {
                    option: function(item, escape) {
                        var apps = [];
                        for (var i = 0, n = item.app_list.length; i < n; i++) {
                            apps.push('<span>' + escape(item.app_list[i].application_name) + '</span>');
                        }

                        return '<div>' +
                              '<span class="name">' +   item.description + '</span>' 
                },
                load: function(term, callback) {
                    if (!term.length) return callback();
                    $.ajax({
                        url: 'http://apiurlgoeshere/getresponse/',
                        type: 'GET',
                        dataType: 'jsonp',
                        data: {
                            term: 'xyz',
                            page_limit: 10,

                        },
                        error: function() {
                            callback();
                        },
                        success: function(res) {
                            console.log(res.app_list);
                            callback(res.app_list);
                        }
                    });
                }

            });

here in the above code, callback is not getting called.

Did the paste go awry? This isn't valid javascript, and you're missing a </div>.

Thanks for reply,
Closing

is there in my code,
I am getting dropdown list, when i am clicking on any option from dropdown, its not storing in textbox

What does the data look like coming from your server? Are you sure valueField is set properly?

I thought I was having this problem too, but as @brianreavis said, the issue was that I was not properly setting my valueField property.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

First character remains highlighted
Wardrop picture Wardrop  路  19Comments

Set selected values in initialization
andriijas picture andriijas  路  21Comments

Required fields can not be focusable
oswaldoacauan picture oswaldoacauan  路  21Comments

Enter key should submit form
nesl247 picture nesl247  路  37Comments

TypeError: $(...).selectize is not a function
nepsdotin picture nepsdotin  路  15Comments