BUGFIX Don't allow dragging tree nodes outside of the root node, don't allow moving the root node, don't access drag/drops from other trees.

This commit is contained in:
Ingo Schommer 2011-03-03 13:59:31 +13:00
parent cf467d5272
commit eb030fa0f9

View File

@ -25,7 +25,28 @@
"select_limit" : 1, "select_limit" : 1,
'initially_select': [treeContainer.find('.current').attr('id')] 'initially_select': [treeContainer.find('.current').attr('id')]
}, },
'plugins': ['themes', 'html_data', 'ui', 'dnd'] "crrm": {
'move': {
// Check if a node is allowed to be moved.
// Caution: Runs on every drag over a new node
'check_move': function(data) {
var movedNode = $(data.o), newParent = $(data.np),
isMovedOntoContainer = data.ot.get_container()[0] == data.np[0];
var isAllowed = (
// Don't allow moving the root node
movedNode.data('id') != 0
// Only allow moving node inside the root container, not before/after it
&& (!isMovedOntoContainer || data.p == 'inside')
);
return isAllowed;
}
}
},
'dnd': {
"drop_target" : false,
"drag_target" : false
},
'plugins': ['themes', 'html_data', 'ui', 'dnd', 'crrm']
}) })
// .bind('before.jstree', function(e, data) { // .bind('before.jstree', function(e, data) {
// if(data.func == 'drag_start') { // if(data.func == 'drag_start') {