mbraak / jqTree

Tree widget for jQuery
https://mbraak.github.io/jqTree/
Apache License 2.0
1.02k stars 177 forks source link

how to create a context menu? #164

Closed eskaigualker closed 11 years ago

eskaigualker commented 11 years ago

We can capture this event, but I don't know how to use it. Which plugin would be useful for creating a secondary menu?

thanks

mbraak commented 11 years ago

I use bootstrap dropdown: http://twitter.github.io/bootstrap/javascript.html#dropdowns

Cheers, Marco

eskaigualker commented 11 years ago

Thank you ,but this can be used to create a right-click menu or just a regular dropdown menu?

mbraak commented 11 years ago

I think you can create a contextmenu by capturing the tree.contextmenu event and a dropdown plugin like bootstrap dropdown. Unfortunately I don't have an example for this.

eskaigualker commented 11 years ago

Well, i got it using http://medialize.github.com/jQuery-contextMenu/ The problem now is when capturing tree.contextmenu event, and adding "jqtree-selected" class to the node, it will not be deselected when cli¡cking in another one. Maybe there is a better way to selecting a node?

mbraak commented 11 years ago

You could use the selectNode function:

$('#tree1').bind(
    'tree.contextmenu',
     function(e) {
         var node = e.node;
         $('#tree1').tree('selectNode', node);
     }
);
eskaigualker commented 11 years ago

Great!! that's it

thank you very much

DavidUv commented 11 years ago

Hi,

I made a little context menu "plugin" to jqTree. Check it out at https://github.com/DavidUv/jqTreeContextMenu if you are interested.

eskaigualker commented 11 years ago

Your plugin works like a charm. Thank you very much!!