Selecting value from ajax-loaded data does not work


Firstly, thank you for the great plugin!

So, the problem:

i have an select with custom data loading:

ajax: {
transport: function (params, success, failure) {

                    var o  = {
                        command: 'getAllStorages',
                        object: 'project',
                        params: {

                    socketQuery(o ,function(res){

                        if(!res.code == 0){
                            return false;

                        var sdata = {
                            results: [{
                                text: "Parental storages",
                                children: []
                                text: "Storages",
                                children: []
                            paginate: {
                                more: true

                        for(var i in res.parent_storage){
                                id: res.parent_storage[i].id,
                                text: res.parent_storage[i].name

                        for(var k in{





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=)

You haven’t shown the code where you actually initialize the select2 widget, but I assume you’re assigning the sdata object as the select2 widget’s data property when you initialize your widget.

Assuming that’s true, I’m guessing that when you say the dropdown works correctly, you mean that you can click in the select2 widget that’s rendered on the page and see the expected data. But what do you mean when you say it doesn’t work when you select a value? What exactly happens after you select an item from the dropdown?

Can you provide a code sample?