Link to home
Start Free TrialLog in
Avatar of dkim18
dkim18

asked on

JsTree loading data?

I am trying to use the JsTree v3.0.

This loads the data into the tree.

$('#tree').jstree({
'core' : {
  'data' : {
    'url' : function (node) {
      return node.id === '#' ? 
        'ajax_roots.json' : 
        'ajax_children.json';
    },
    'data' : function (node) {
      return { 'id' : node.id };
    }
  }
});

Open in new window


Q1) I also saw you can use the .ajax inside of above code.
What's the difference?
THis one use .ajax to request.

$('#file_tree').jstree({
    "plugins": ["json_data", "themes", "ui", "crrm", "dnd", "search", "contextmenu"],
      "json_data" : 
    {
    [quote]    "ajax" : 
        {
            "url" : "{{ url('components/tree/findall') }}",
[/quote]                       "data" : function (node) { 
                    console.info("Nodes:",node);    
                     return {   
                            "operation" : "get_children",
                            "id" : node.attr ? node.attr("id").replace("node_","") : 1
                        };
                    }
        }
    }
})

Open in new window

SOLUTION
Avatar of lenamtl
lenamtl
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dkim18
dkim18

ASKER

I should had made url to contain same name in both example above.
Let's assume that they are both coming from the web service.

What's the difference?