| Issue 183: | Not able to get the selected node details on right click | |
| 1 person starred this issue and may be notified of changes. | Back to list |
Hi, I am facing very simple problem in dynatree context menu. I am not able to get the selected node details on right click. What i am doing just describing belows: 1. I just refered the following link example . http://wwwendt.de/tech/dynatree/doc/samples.html (ContextMenu Copy Paste example) 2. I am having two tree in my application , is dynamic added node in tree when page is loaded ,after that my context menu added in both tree. As per example ContextMenu is added by following methods. function bindContextMenuForOneTree() { // Add context menu to all nodes: $("span.dynatree-node") .destroyContextMenu() // unbind first, to prevent duplicates .contextMenu({menu: "myMenu"}, function(action, el, pos) { // The event was bound to the <span> tag, but the node object // is stored in the parent <li> tag var node = el.parent().attr("dtnode"); switch( action ) { case "cut": case "copy": case "paste": copyPaste(action, node); break; default: alert("Todo: appply action '" + action + "' to node " + node); } }); }; function bindContextMenuForOneTree() { // Add context menu to all nodes: $("span.dynatree-node") .... ...Same Code as Above ... ... }); }; So context menu is not added in both tree. so i used unique tree id instead of span class . then i able to get the contextmenu in both tree. but the problem is that i m not able to get the node . i used alert to see the 'action' ,'el' and 'pos'. i m able to get all value as object var node = el.parent().attr("dtnode"); but not able to get the node . please help me for it. Thanks in Advance.
Feb 23, 2011
$("span.dynatree-node") already matches the nodes of both trees.
If you want to bind different handlers, you need different selectors like
$("#tree span.dynatree-node")
and
$("#tree2 span.dynatree-node")
Status:
Waiting
Labels: -Type-Defect Type-Other
Feb 24, 2011
Thanks you so much for your quick response. I used same as you suggested . but now i am not able to see the context menu on right click.
Feb 24, 2011
Hello ,
I just tried this example using one tree so it is working fine. but in the case of multiple tree in web page it is not working."span.dynatree-node" matches the node of multiple tree .
please look on it. how could i solved this problem?
i also tried to give a treeid like this :
$("#tree span.dynatree-node")
$("#tree1 span.dynatree-node")
$("#tree2 span.dynatree-node")
but it is not worked for me. my bad luck (:
Feb 24, 2011
Hello ,
$("span.dynatree-node") already matches the nodes of both trees.
If you want to bind different handlers, you need different selectors like
$("#tree span.dynatree-node")
and
$("#tree2 span.dynatree-node")
Reply :
I tried a lot of times but i could not able to solved this problem. if you can provide some sample example / source code so i can look on it and get better idea to understand.
Feb 24, 2011
This seems to be rather a Context menu (or even jQuery) question, not a specific dynatree issue. I suggest, that you post this in the group, maybe others have already solved this use case. (A complete working sample (HTML files) would help to reproduce your problem.)
May 31, 2011
I got the same problem too (node = undefined when context menu popup) with jQuery 1.6. I have to use jQuery 1.5 now & I changed 'jquery.contextMenu-custom.js', added prePopupCallback (it gets & selects the node) & call it before the menu popup.
Dec 28, 2011
r543 says jQuery 1.7.1 is used, so this is fixed? The getNode() function returns null for me using r543 and jQuery 1.7.1.
Dec 29, 2011
This issue was updated by revision r570.
Feb 20, 2012
Can you please share the js file referring comment 7 that says "I have to use jQuery 1.5 now & I changed 'jquery.contextMenu-custom.js', added prePopupCallback (it gets & selects the node) & call it before the menu popup."
Jun 7, 2013
can any one help to bind the dynamic values to from tree structure,how to bind the parent and child values in dynamic
am using dynatree
<link href="../Media/Js/ui.dynatree.css" rel="stylesheet" type="text/css" id="skinSheet" />
<script src="../Media/Js/jquery.dynatree.js" type="text/javascript"></script>
Thanks in advance
Oct 6, 2013
Closing 'Waiting' issues without timely answer
Status:
Done
May 2, 2014
Cleanup Scrumboard
Labels:
Milestone-Release2.0
|
Sorry i did one mistake in it . i putted two methods with same name but it is different like below: function bindContextMenuForOneTree() { // Add context menu to all nodes: $("span.dynatree-node") .destroyContextMenu() // unbind first, to prevent duplicates .contextMenu({menu: "myMenu"}, function(action, el, pos) { // The event was bound to the <span> tag, but the node object // is stored in the parent <li> tag var node = el.parent().attr("dtnode"); switch( action ) { case "cut": case "copy": case "paste": copyPaste(action, node); break; default: alert("Todo: appply action '" + action + "' to node " + node); } }); }; function bindContextMenuForTWOTree() { // Add context menu to all nodes: $("span.dynatree-node") .... ...Same Code as Above ... ... }); };