Configuring jsTree for AJAX

2

I'm using the jsTree plugin, trying to get it to fetch the information by AJAX .

On server side I have four tables in the database, each one a level of the tree.

Tabela1
-Tabela2
--Tabela3
---Tabela4

Making the plugin search the first level was easy:

$("#tree").jstree({
    core: {
        data: {
            url: "/tabela1.json"
        }
    }
});

But I'm not able to hit the syntax to make it fetch the other level, at the click of the user.

The two attempts below did not work:

$("#tree").jstree({
    core: {
        data: {
            url: "/tabela1.json",
            data: "/tabela2.json"
        }
    }
});

$("#tree").jstree({
    core: {
        data: {
            url: "/tabela1",
            data: {
                url: "/tabela2.json"
            }
        }
    }
});
    
asked by anonymous 22.09.2014 / 17:44

1 answer

1

Why do not you call the tables each one at a time?

var urls = [];
urls[0] = "/tabela1.json";
urls[1] = "/tabela2.json";
urls[2] = "/tabela3.json";
urls[3] = "/tabela4.json";

for(i=0; i < urls.length){
    $("#tree").jstree({
        core: {
            data: {
                url: urls[i];
            }
        }
    });
}
    
23.09.2014 / 05:09