How to disable drag and drop function in jsTree? I want to disable moving nodes. How can I achieve this?
just add this:
"default" : { draggable : false },
It should be in the types: section.
Plain. Do not add dnd parameter to plugins
This includes drag and drop features.
"plugins": ["themes","html_data","dnd","ui","types"]
Disables the drag and drop function.
"plugins": ["themes","html_data","ui","types"]
This has changed in the new version of JSTree.
The way I did it (in version 1.0) was in the crrm section. My check_move looked like this:
"check_move" : function (m) { return (modata("rel")=="itemsetting" ? false : true); }
modata ("rel") is how you drag the node type.
This makes a node of this type impossible to drag, pointing to the X icon no matter where the node drags.
"Dnd" is not added to types. You can also use the property on pluggin, this will disable all movement.
dnd: { "is_draggable": function (node) { return false; // flip switch here. } },
I wanted to disable drag and drop for disabled nodes, this worked:
const config = { plugins: ['dnd', ...], dnd: { is_draggable: node => !node[0].state.disabled, }, }