Load / append data on click of node #10

Closed
aaronlcope opened this Issue Apr 9, 2012 · 4 comments

3 participants

@aaronlcope

I don't see a way to append new data to an existing node when you click it. Is there a way to issue an ajax request for more data under a particular node and have this plugin append more nodes via JSON formatted responses?

If this already exists, is there any sample code anywhere?

@mbraak
Owner

At this moment it's not possible to add nodes dynamically to the tree. I think it would be a nice feature, though.

It is possible to load a whole new tree using the function loadData (http://mbraak.github.com/jqTree/#functions-loadData).

@mbraak
Owner

The 'dev' branch contains a new feature for loading a subtree. The function 'loadData' now accepts a 'parent_node' parameter.

$tree.tree('loadData', data, parent_node);

Example for loading subtree on click:

$('#tree1').bind(
    'tree.click',
    function(e) {
        var node = e.node;

        $.getJSON(
            '/get-data/',
            function(data) {
                $tree.tree('loadData', data, node);
            }
        );
    }
);
@mbraak
Owner

Implemented in version 0.7

@mbraak mbraak closed this Apr 23, 2012
@rosenfeld

There is still an issue here. 'tree.click' event won't be always triggered. For example, if you try to move a node to inside a closed node, it will open the node but won't trigger the 'tree.click' event.

I'll create a separate issue since this was already closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment