Inspire Tree

Demo: Dynamic Children

When data is a function the tree invokes it when any node with children: true is expanded.

var tree = new InspireTree({
    data: function(node, resolve, reject) {
        var id = node ? node.id : 'root';
        return $.getJSON('a/url?id=' + id));
    }
});

new InspireTreeDOM(tree, {
    target: '.tree'
});

You can either return a promise (jQuery/$http/Promise/etc) or manually pass results into the resolve function.

Results are cached to avoid redundant calls.