").addClass("node")
- .data("tree-node", nodeCount)
- .append($nodeContent);
+
+ //Increaments the node count which is used to link the source list and the org chart
+ nodeCount++;
+ $node.data("tree-node", nodeCount);
+ $nodeDiv = $("
").addClass("node")
+ .data("tree-node", nodeCount)
+ .append($nodeContent);
// Expand and contract nodes
if ($childNodes.length > 0) {
@@ -142,10 +142,16 @@
$this.css('cursor','n-resize');
$tr.removeClass('contracted').addClass('expanded');
$tr.nextAll("tr").css('visibility', '');
+
+ // Update the
appropriately so that if the tree redraws collapsed/non-collapsed nodes
+ // maintain their appearance
+ $node.removeClass('collapsed');
}else{
$this.css('cursor','s-resize');
$tr.removeClass('expanded').addClass('contracted');
$tr.nextAll("tr").css('visibility', 'hidden');
+
+ $node.addClass('collapsed');
}
});
}
@@ -156,7 +162,7 @@
if($childNodes.length > 0) {
// if it can be expanded then change the cursor
- $nodeDiv.css('cursor','n-resize').addClass('expanded');
+ $nodeDiv.css('cursor','n-resize');
// recurse until leaves found (-1) or to the level specified
if(opts.depth == -1 || (level+1 < opts.depth)) {
@@ -165,7 +171,7 @@
$downLineRow.append($downLineCell);
// draw the connecting line from the parent node to the horizontal line
- var $downLine = $("").addClass("line down");
+ $downLine = $("").addClass("line down");
$downLineCell.append($downLine);
$tbody.append($downLineRow);
@@ -204,7 +210,8 @@
var classList = $node.attr('class').split(/\s+/);
$.each(classList, function(index,item) {
if (item == 'collapsed') {
- $nodeRow.nextAll('tr').css('display', 'none');
+ console.log($node);
+ $nodeRow.nextAll('tr').css('visibility', 'hidden');
$nodeRow.removeClass('expanded');
$nodeRow.addClass('contracted');
$nodeDiv.css('cursor','s-resize');