Call 'getData' method to get a node data, get the root node data and store it in somewhere. To restore the tree, call 'loadData' method and pass the original root node data as its parameter. The code looks like this:
var root = $('#tt').tree('getRoot'); // get root node
var data = $('#tt').tree('getData', root.target); // get the root node data
// now restore the tree
$('#tt').tree('loadData', [data]);
The 'getData' method is implemented as below:
$.fn.tree.methods.getData = function(jq, target){
function retrieveChildData(aa, ul){
ul.children('li').each(function(){
var node = $(this).children('div.tree-node');
var nodedata = jq.tree('getNode', node[0]);
var sub = $(this).children('ul');
if (sub.length){
nodedata.children = [];
retrieveChildData(nodedata.children, sub);
}
aa.push(nodedata);
});
}
var nodedata = jq.tree('getNode', target);
nodedata.children = [];
retrieveChildData(nodedata.children, $(target).next());
return nodedata;
};