My favorites | Sign in
Project Home Downloads
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
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
Status:  Done
Owner:  ----
Closed:  Oct 2013


 
Reported by jigarnag...@gmail.com, Feb 23, 2011
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
#1 jigarnag...@gmail.com
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
...
...
    });
  }; 
Feb 23, 2011
Project Member #2 moo...@wwwendt.de
$("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
#3 jigarnag...@gmail.com
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
#4 jigarnag...@gmail.com
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
#5 jigarnag...@gmail.com
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
Project Member #6 moo...@wwwendt.de
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
#7 mrdu...@gmail.com
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
Project Member #8 wbgil...@gmail.com
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
Project Member #9 moo...@wwwendt.de
This issue was updated by revision r570.
Feb 20, 2012
#10 vbor...@gmail.com
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
#12 karthick...@gmail.com
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
Project Member #13 moo...@wwwendt.de
Closing 'Waiting' issues without timely answer
Status: Done
May 2, 2014
Project Member #14 moo...@wwwendt.de
Cleanup Scrumboard
Labels: Milestone-Release2.0

Powered by Google Project Hosting