Skip to content

Instantly share code, notes, and snippets.

@lanceon
Created May 1, 2014 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lanceon/72742d98151c0140851e to your computer and use it in GitHub Desktop.
Save lanceon/72742d98151c0140851e to your computer and use it in GitHub Desktop.
jqTree - collapse/expand tree
var $tree = $('#tree1');
$('#collapse').click(function() {
var tree = $tree.tree('getTree');
tree.iterate(function(node) {
if (node.hasChildren()) {
$tree.tree('closeNode', node, true);
}
return true;
});
});
$('#expand').click(function() {
var tree = $tree.tree('getTree');
tree.iterate(function(node) {
if (node.hasChildren()) {
$tree.tree('openNode', node, true);
}
return true;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment