fancytree
fancytree copied to clipboard
moveTo func breaks the tree when moving a top level node to root node
-fancytree version: 2.0.0 -using with table extension -jQuery v1.7.2, jQuery UI 1.8.16 pls refer http://jsfiddle.net/wA6Zy/
Step to reproduce bug:
- Create a tree with only one data node, here is the sample of tree initialization
$("#fancytree").fancytree({
extensions: ["table"],
selectMode: 2, //single
checkbox: true,
icons: false,
table: {
indentation: 20, // indent 20px per node level
nodeColumnIdx: 1, // render the node title into the 2nd column
checkboxColumnIdx: 0 // render the checkboxes into the 1st column
},
source: [{
title: 'Hello',
key: '11'
}]
});
- Try to move the node to rootNode, then the node will disappear and even the tree cannot reload new data.
var ft = $("#fancytree").fancytree("getTree");
var node = ft.getNodeByKey("11");
node.moveTo(ft.rootNode);
Potential fix: Should do nothing in this case as the node is on its correction position already
//jquery.fancytree.js:1050
if(this.parent.isRoot() === true && targetParent.isRoot() === true) {
return;
}