I have problem in selectize JS when set current value is multiple value. I set from Ajax response in Json format, here is my code.
$(".rule_list").on("click",function(e) {
e.preventDefault();
$.ajax({
url: 'getruledata,
dataType: 'json'
})
.done(function(data){
console.log(data);
$selectz[0].selectize.setValue(data[0].control_country);
})
});
Here my HTML code
<select id="select-country" placeholder="Pick a countries..."></select>
And here code for selectize
var $selectz = $('#select-country').selectize({
maxItems: null,
valueField: 'iso',
labelField: 'nice_name',
searchField: 'nice_name',
options: {!! $country !!},
create: false,
});
Here my value format from Json response
[{"id":2,"name":"XSA 2","user_id":"3","control_device":"Mobile","control_country":"US,CA","offer_id":"2","rule_id":"1","status":"2"}]
I'm stuck in this steps, if "control_country":"US,CA"
(multiple value) not working when set current value to input form, but if "control_country":"US"
(single value) working correctly