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,
onCanMoveTo: function(moved_node, target_node, position) {
console.log('movedNode',moved_node);
console.log('targetedNode',target_node);
console.log('position',position);
if (position == 'inside') {
return (moved_node.parent == target_node);
}
else if (position == 'after') {
return (moved_node.parent == target_node.parent);
}
else {
return false;
}
}
});
});
Above is my code, As you can see I want to achieve that, no node can be moved from its level, it should remain inside its level and its position inside the level can be changed. Need help to find why onCanMoveTo never work.