I have a fancytree populated with some json. I also have a droppable div. I want to be able to drag nodes within the tree (ie to move stuff about within the contained hierarchy) and I want to be able to drag stuff from the tree into my external droppable div.
How can I do this?
Here's what I have:
My html:
<div id="tree"></div>
<div id="droppable">
stuff
</div>
dnd initialisation options:
{
autoExpandMS: 400,
focusOnClick: true,
preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
preventRecursiveMoves: true, // Prevent dropping nodes on own descendants
dragStart: function(node, data) {return true;},
dragEnter: function(node, data) {return true;},
dragDrop: function(node, data) {data.otherNode.moveTo(node, data.hitMode);},
draggable: {
containment: 'document',
scroll : false,
scrollSpeed: 7,
scrollSensitivity: 10,
}
},
droppable initialisation
$('#droppable').droppable({
onDrop : function(e,source){
alert('dropped: '+source.textContent);
window.dropped = source;
window.event = e;
},
});
Extensions:
I'm making use of ["dnd","edit","contextMenu"] extensions. I'm mentioning this in case there is some conflict I am not aware of... I did however disable the edit and contextMenu to no avail.
Behavior:
- The contextMenu and edit extensions work fine.
- I can drag and drop items within the tree to reorder nodes.
- I cannot drag stuff out of the tree
- with
scroll: true
the tree just gets some scrollbars that scroll to infinity as I drag over the edge - with
scroll: false
the tree scrollbars behave the same but no actual scrolling occurs - containment seems to have no effect
- with
Included resources:
- jquery.js jquery-ui-1.11.0.js
- jquery.fancytree-all.css
- jquery.contextMenu.css
- jquery.contextMenu-1.6.5.js
- jquery.fancytree.contextMenu.js
- fancytree.min.css