v1.16.0
Use a custom shouldLoadNodes function to return a boolean value to determine whether to load nodes on demand (07cec31, #30)
var tree = new InfiniteTree({
el: document.querySelector('#tree'),
data: [
{ // node
id: '<unique-node-id>', // Required
name: 'Node 0',
loadNodes: true
}
],
shouldLoadNodes: function(parentNode) {
return !parentNode.hasChildren() && parentNode.loadNodes;
},
loadNodes: function(parentNode, next) {
var nodes = [
{
id: 'node1',
name: 'Node 1'
},
{
id: 'node2',
name: 'Node 2'
}
];
setTimeout(function() {
next(null, nodes, function() {
// Completed
});
}, 1000);
}
});