Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function($) {
- $.ajax({
- url: 'data.json',
- }).done(function(data){
- data = JSON.parse(data);
- data = $.map(data, function(val){
- val.nested = $.map(val.nested, function(val2){
- return { 'text': val2.label, 'type': val2.type, 'description': val2.description };
- });
- return { 'text': val.label, 'type': val.type, 'description': val.description, 'children': val.nested };
- });
- $('#tree').jstree({
- 'core': {
- 'data': data
- },
- 'types': {
- 'file': {
- 'icon': 'jstree-file'
- },
- 'dir': {
- 'icon': 'jstree-folder'
- }
- },
- 'plugins': [ 'types' ]
- });
- });
- $('#tree').on('changed.jstree', function(e, data){
- $("#description").text(data.node.original.description);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement