Hi!
Firstly, thank you for the great plugin!
So, the problem:
i have an select with custom data loading:
formWrapper.find(’.select-storage-holder’).select2({
ajax: {
transport: function (params, success, failure) {
var o = {
command: 'getAllStorages',
object: 'project',
params: {
id: formInstance.data.data[0].project_id
}
};
socketQuery(o ,function(res){
if(!res.code == 0){
toastr[res.toastr.type](res.toastr.message);
return false;
}
var sdata = {
results: [{
text: "Parental storages",
children: []
},{
text: "Storages",
children: []
}],
paginate: {
more: true
}
};
for(var i in res.parent_storage){
sdata.results[0].children.push({
id: res.parent_storage[i].id,
text: res.parent_storage[i].name
});
}
for(var k in res.storage){
sdata.results[1].children.push({
id: res.storage[k].id,
text: res.storage[k].name
})
}
console.log(sdata);
success(sdata);
});
}
}
});
Data in console before adding to select (converted to JSON):
{“results”:[{“text”:“Parental storages”,“children”:[{“id”:7,“text”:“Storage in TheGreatProject”,“selected”:true}]},{“text”:“Storages”,“children”:[{“id”:8,“text”:“storage in test7”}]}],“paginate”:{“more”:true}}
Dropdown works correctly, but when i try to select some value it does not works.
Please help=)