Reputation: 2673
I'm using selectize like this:
$('#category_field').selectize({
valueField: 'name',
searchField: 'name',
delimiter: "/",
options: [],
load: function(query,callback)
{
if(!query.length) return callback();
$.ajax({
url: '/categories/autocomplete',
type: 'GET',
dataType: 'jsonp',
data: {
},
error: function() {
callback();
},
success: function(res) {
callback(res.movies);
}
});
}
}
);
"#category_field" is just a form input of type text.
I verified that the ajax request is being made and the response from the server looks like this:
[
{
"_id": {
"$oid": "568bee09421aa908fe000009"
},
"depth": 0,
"name": "math",
"parent_id": null,
"parent_ids": [],
"picture": {
"url": "/uploads/category/picture/568bee09421aa908fe000009/Screenshot________________.png",
"thumb": {
"url": "/uploads/category/picture/568bee09421aa908fe000009/thumb_Screenshot________________.png"
}
}
}
]
My problem is that the autocomplete dropdown menu doesn't even show, what to do ?
I just wanted to mention that I'm using bootstrap 3 , the input field and the label for it are wrapped inside <div class=field>...</div>
, this div is wrapped inside the form which is wrapped inside container inside panel.
Does this relate to the problem ?
Upvotes: 0
Views: 751
Reputation: 663
What i noticed
You are not passing any query to the service
You have to set preLoad true to load the options or have to set preLoad in focus to set the options initially
or
You have to initialize the option with the array as like your response
Upvotes: 0
Reputation: 1847
This response not looks like a valid JSON. Check console, or/and use trycatch
try { $.ajax(...) } catch (err) { console.error(err); }
And JSONP is crossDomain method, maybe you can try delete it.
Upvotes: 0