Advertisement
Guest User

Untitled

a guest
May 30th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery(document).ready(function($) {
  2.     $.ajax({
  3.         url: 'data.json',
  4.     }).done(function(data){
  5.         data = JSON.parse(data);
  6.         data = $.map(data, function(val){
  7.        
  8.             val.nested = $.map(val.nested, function(val2){
  9.                 return { 'text': val2.label, 'type': val2.type, 'description': val2.description };
  10.             });
  11.            
  12.             return { 'text': val.label, 'type': val.type, 'description': val.description, 'children': val.nested };
  13.         });
  14.        
  15.         $('#tree').jstree({
  16.             'core': {
  17.                 'data': data
  18.             },
  19.             'types': {
  20.                 'file': {
  21.                     'icon': 'jstree-file'
  22.                 },
  23.                 'dir': {
  24.                     'icon': 'jstree-folder'
  25.                 }
  26.             },
  27.             'plugins': [ 'types' ]
  28.         });
  29.     });
  30.    
  31.     $('#tree').on('changed.jstree', function(e, data){
  32.         $("#description").text(data.node.original.description);
  33.     });
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement