JsTree function - disable drag and drop

How to disable drag and drop function in jsTree? I want to disable moving nodes. How can I achieve this?

+6
drag-and-drop jstree
source share
5 answers

just add this:

"default" : { draggable : false }, 

It should be in the types: section.

+1
source share

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"]

+8
source share

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.

+1
source share

"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. } }, 
0
source share

I wanted to disable drag and drop for disabled nodes, this worked:

 const config = { plugins: ['dnd', ...], dnd: { is_draggable: node => !node[0].state.disabled, }, } 
0
source share

All Articles