Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion jquery.jOrgChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$this = $(this);
var $container = $("<div class='" + opts.chartClass + "'/>");
if($this.is("ul")) {
buildNode($this.find("li:first"), $container, 0, opts);
buildNodes($this, $container, opts);
}
else if($this.is("li")) {
buildNode($this, $container, 0, opts);
Expand Down Expand Up @@ -102,6 +102,25 @@
dragAndDrop: false
};

function buildNodes($list, $appendTo, opts) {
var $table = $("<table cellpadding='0' cellspacing='0' border='0'/>");
var $tbody = $("<tbody/>");

// Construct the node container(s)
var $nodeRow = $("<tr/>");
$list.children("li").each(function(i, elem) {
var $td = $("<td class='node-container'/>");
$td.attr("colspan", 2);

buildNode($(elem), $td, 0, opts);
$nodeRow.append($td);
});

$tbody.append($nodeRow);
$table.append($tbody);
$appendTo.append($table);
}

var nodeCount = 0;
// Method that recursively builds the tree
function buildNode($node, $appendTo, level, opts) {
Expand Down