-1
我想將subchild移動到子節點,但我不想將subchild移動到父節點。我可以將childnode移動到另一個父節點,但它不能是父節點。 jqtree更好還是更適合約束條件。jqtree移動子節點
var data = [
{
label: 'node1',
children: [
{ label: 'child1',
children: [
{ label: 'sub-child1' }
]
},
{ label: 'child2' }
]
},
{
label: 'node2',
children: [
{ label: 'child3' }
]
}
];
$(function() {
$('#tree1').tree({
data: data,
dragAndDrop: true,
/*onCanMove: function(node) {
if (! node.parent.parent) {
// Example: Cannot move root node
return false;
} else {
return true;
}
},*/
onCanMoveTo: function(moved_node, target_node, position) {
console.log(node);
if (target_node == moved_node.parent.parent) {
return (position == 'inside');
}
else {
return true;
}
}
});
});
$('#tree1').on("click",function() {
var node = $('#tree1').tree('getSelectedNode');
console.log(node.name);
});
爲何我downvoted? – user525146