How I can use selectize.js with remote source? I have followed this example:
$('#select-repo').selectize({
valueField: 'url',
labelField: 'name',
searchField: 'name',
create: false,
render: {
option: function(item, escape) {
return '<div>' +
'<span class="title">' +
'<span class="name"><i class="icon ' + (item.fork ? 'fork' : 'source') + '"></i>' + escape(item.name) + '</span>' +
'<span class="by">' + escape(item.username) + '</span>' +
'</span>' +
'<span class="description">' + escape(item.description) + '</span>' +
'<ul class="meta">' +
(item.language ? '<li class="language">' + escape(item.language) + '</li>' : '') +
'<li class="watchers"><span>' + escape(item.watchers) + '</span> watchers</li>' +
'<li class="forks"><span>' + escape(item.forks) + '</span> forks</li>' +
'</ul>' +
'</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: 'https://api.github.com/legacy/repos/search/' + encodeURIComponent(query),
type: 'GET',
error: function() {
callback();
},
success: function(res) {
callback(res.repositories.slice(0, 10));
}
});
}
});
And works fine as it is. If I change the url with mine it stops working.
Example response from remote remote url:
[
{
"id":2,
"title":"Facere sequi dolore dignissimos eum aut et."
},
{
"id":3,
"title":"Perspiciatis laudantium aut eos autem dolor quisquam."
},
{
"id":10,
"title":"Enim provident vel rerum laborum quis nobis."
},
{
"id":25,
"title":"Porro earum nihil recusandae rerum ratione sunt."
}
]
I used console.log inside load function and the response is good. Even though there is no dropdown in the select box. I have been trying to make it work for over 3 hours with no success.