Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $.ajax({
- url: 'data.json',
- dataType: 'json',
- success: function(data) {
- /*var arr = $.map(data, function(item){
- //item.set = data[item.set];
- //console.log(item);
- return item;
- });
- for (var i = 0; i<arr.length; i++) {
- var array = $.map(arr[i].nested, function(child){
- return child;
- });
- for(var j = 0;j<array.length;j++){
- array[j].text=array[j].label;
- delete array[j].label;
- }
- arr[i].children = array;
- arr[i].text = arr[i].label;
- delete arr[i].label;
- delete arr[i].nested;
- }*/
- var arr=$.map(data, function(obj){
- return{
- text:obj.label,
- type:obj.type,
- description:obj.description,
- children:$.map(obj.nested,function(test){
- return{
- text:test.label,
- type:test.type,
- description:test.description}
- }
- )
- }})
- console.log(arr);
- $('#tree').jstree({
- 'core': {
- 'data': arr
- },
- 'types': {
- 'file': {
- 'icon': 'jstree-file'
- },
- 'dir': {
- 'icon': 'jstree-folder'
- }
- },
- 'plugins': [ 'types' ]
- });
- console.log(arr);
- },
- statusCode: {
- 404: function() {
- alert('There was a problem with the server. Try again soon!');
- }
- }
- });
- // $.ajax({...});
- alert("Działam - JavaScript :)");
- // TODO
- });
- $("#tree").on("changed.jstree",function(e,data){
- //alert("dupa");
- $("#description").text(data.node.original.description);
- })
- /*$(".jstree").click(function(){
- alert("dupa");
- $("#description").text(event.node.original.description);
- });*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement