title: How to replace dynatree node with new node?
body: <p>I have created a dynatree with right contex menu which further has a sub-menu. The requirement is such that on click of any of the item of the sub-menu, the sub-menu item should replace the tree node from which is activated. Followin is the pictorial view:</p>
  
  <pre><code>ABC
  DEF
  GHI-&gt; Lets say on right click of GHI, we have a context menu-&gt;XYZ which further has a sub-menu-&gt; PQR. Now what I want is that on click of PQR, it should replace GHI.
  </code></pre>
  
  <p>I have the following code written to create the tree and context menus.</p>
  
  <pre><code>$(function(){
          $("#tree").dynatree({
  
              initAjax: {
                  url: "sample-data1.json"
                  }  ,
              onActivate: function(node) {
                  $("#echoActive").text(node.data.title);
  
              },
              onDeactivate: function(node) {
                  $("#echoActive").text("-");
              }
  
  
          });
      }); 
  
  function ReplaceTest() {
                  var tree = $("#tree").dynatree("getTree");
  
  
                  }
  
  
       function Replace()
              {
                  var f = function(){ReplaceTest();};
                  setTimeout(f,0);
  
              }
  
   &lt;div&gt;
      &lt;ul id="myMenu" class="contextMenu"&gt;
              &lt;li&gt;&lt;a href="#"&gt;Employee Data&lt;/a&gt;
              &lt;ul&gt;         
    &lt;li&gt;&lt;a href="#" onclick="Replace()"&gt;Name&lt;/a&gt;&lt;/li&gt;         
    &lt;li&gt;&lt;a href="#" onclick="Replace()"&gt;Desig&lt;/a&gt;&lt;/li&gt;           
    &lt;li&gt;&lt;a href="#" onclick="Replace()"&gt;ID&lt;/a&gt;&lt;/li&gt;          
    &lt;li&gt;&lt;a href="#" onclick="Replace()"&gt;Mob&lt;/a&gt;&lt;/li&gt;        
    &lt;/ul&gt; 
              &lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In the above code I've given onclick() method on sub-menu items, but not able to go ahead with this. Please help.</p>