1
votes

Currently I'm trying to figure out if it's possible to attach the default contextmenu jstree uses, to a foreign node ?

To explain my scenario please go to this link and go to the bottom of the page. In the first demo you can drag'n'drop a foreign node (being "I have the jstree-draggable class") to the folders in jstree.
I'm trying to understand if it's possible to attach the jstree contextmenu plugin to that foreign node?

1
It's certainly possible, though you'll have to either modify show_contextmenu in jstree source to have it accept non-nodes, or override it with your own method, maybe pilfering from the source as necessary. Since foreign contextual items should have less tree-relevant actions, it might be a good idea just to steal the code/style and create a separate context menu for foreign nodes. - glortho

1 Answers

0
votes

Yeah it's possible to attach contextmenu to foreign nodes in jstree. You should keep in mind, though, you'll need to rewrite a lot of code if you're using different html from what you have in the tree.

In my case this was not acceptable because I had to rewrite more than half of the library so I could get it to work with my html structure.

Creating a separate context menu (as @Jed suggested) is also an option - if you have the time to deal with all the problems that will come. :)