diff --git a/jquery.jOrgChart.js b/jquery.jOrgChart.js
index ed2ed1f..0052f62 100644
--- a/jquery.jOrgChart.js
+++ b/jquery.jOrgChart.js
@@ -72,23 +72,23 @@
var targetID = $(this).data("tree-node");
var targetLi = $this.find("li").filter(function() { return $(this).data("tree-node") === targetID; } );
var targetUl = targetLi.children('ul');
-
- var sourceID = ui.draggable.data("tree-node");
- var sourceLi = $this.find("li").filter(function() { return $(this).data("tree-node") === sourceID; } );
+
+ var sourceID = ui.draggable.data("tree-node");
+ var sourceLi = $this.find("li").filter(function() { return $(this).data("tree-node") === sourceID; } );
var sourceUl = sourceLi.parent('ul');
if (targetUl.length > 0){
- targetUl.append(sourceLi);
+ targetUl.append(sourceLi);
} else {
- targetLi.append("
").addClass("node")
+ nodeCount++;
+ $node.data("tree-node", nodeCount);
+ $nodeDiv = $("
").addClass("node")
.data("tree-node", nodeCount)
.append($nodeContent);
// Expand and contract nodes
- if ($childNodes.length > 0) {
+ if ($childNodes.length > 0 && opts.collapsible) {
$nodeDiv.click(function() {
var $this = $(this);
var $tr = $this.closest("tr");
@@ -155,15 +156,16 @@
}
});
}
-
+
$nodeCell.append($nodeDiv);
$nodeRow.append($nodeCell);
$tbody.append($nodeRow);
if($childNodes.length > 0) {
// if it can be expanded then change the cursor
- $nodeDiv.css('cursor','n-resize');
-
+ if(opts.collapsible){
+ $nodeDiv.css('cursor','n-resize');
+ }
// recurse until leaves found (-1) or to the level specified
if(opts.depth == -1 || (level+1 < opts.depth)) {
var $downLineRow = $("
");
@@ -210,11 +212,13 @@
var classList = $node.attr('class').split(/\s+/);
$.each(classList, function(index,item) {
if (item == 'collapsed') {
- console.log($node);
- $nodeRow.nextAll('tr').css('visibility', 'hidden');
- $nodeRow.removeClass('expanded');
- $nodeRow.addClass('contracted');
- $nodeDiv.css('cursor','s-resize');
+ if(opts.collapsible){
+ window.console && console.log($node); //firefox crashes in some versions without this check
+ $nodeRow.nextAll('tr').css('visibility', 'hidden');
+ $nodeRow.removeClass('expanded');
+ $nodeRow.addClass('contracted');
+ $nodeDiv.css('cursor','s-resize');
+ }
} else {
$nodeDiv.addClass(item);
}