diff --git a/jquery.jOrgChart.js b/jquery.jOrgChart.js index ed2ed1f..9304d46 100644 --- a/jquery.jOrgChart.js +++ b/jquery.jOrgChart.js @@ -21,7 +21,7 @@ $this = $(this); var $container = $("
"); 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); @@ -102,6 +102,25 @@ dragAndDrop: false }; + function buildNodes($list, $appendTo, opts) { + var $table = $(""); + var $tbody = $(""); + + // Construct the node container(s) + var $nodeRow = $(""); + $list.children("li").each(function(i, elem) { + var $td = $("
"); + $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) {