jquery - How to replace dynatree node with new node? -


i have created dynatree right contex menu further has sub-menu. requirement such on click of of item of sub-menu, sub-menu item should replace tree node activated. followin pictorial view:

abc def ghi-> lets on right click of ghi, have context menu->xyz further has sub-menu-> pqr. want on click of pqr, should replace ghi. 

i have following code written create tree , context menus.

$(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);              }   <div>     <ul id="mymenu" class="contextmenu">             <li><a href="#">employee data</a>             <ul>            <li><a href="#" onclick="replace()">name</a></li>            <li><a href="#" onclick="replace()">desig</a></li>              <li><a href="#" onclick="replace()">id</a></li>             <li><a href="#" onclick="replace()">mob</a></li>           </ul>              </li>     </ul> </div> 

in above code i've given onclick() method on sub-menu items, not able go ahead this. please help.

if want rename current node, can use

var node = $("#tree").dynatree("getactivenode"); node.data.title = "my new title"; node.render(); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -