Jstree using API BeforeChange:function() {log ("about-to-change");return true}, Beforeopen:function() {log ("About to open");return true}, BeforeClose:function() {log ("about to close");return true}, Beforemove:function() {log ("About to move");return true}, Beforecreate:function() {log ("about to create");return true}, Beforerename:function() {log ("About to rename");return true}, BeforeDelete:function() {log ("about to delete");return true}, Onselect:function() {log ("select"); }, Ondeselect:function() {log ("deselect")); }, OnChange:function() {log ("Focus changed")); }, Onrename:function() {log ("Rename")); }, OnMove:function() {log ("Move"); }, Oncopy:function() {log ("Copy"); }, OnCreate:function() {log ("Create"); }, OnDelete:function() {log ("Delete"); }, OnOpen:function() {log ("Open"); }, Onopen_all:function() {log ("Open all"); }, OnClose:function() {log ("Close"); }, Error:function() {}, ONDBLCLK:function() {log ("Doubleclick")); TREE_OBJ.toggle_branch.call (Tree_obj, NODE); TREE_OBJ.select_branch.call (Tree_obj, NODE); }, ONRGTCLK:function() {log ("RightClick")); }, onload:function() {log ("Tree loaded")); }, onfocus:function() {log ("Tree got Focus"); }, OnDrop:function() {log ("Foreign node Dropped")); } $("#Organizediv"). Jstree ({"Plugins": ["Thems", "Html_data", "UI", "CRRM", "cookies", "DND", "Search", "types", "hotkeys", "ContextMenu"], "Types": { "Types": { "Department": { "Valid_children": ["department", "Root"], "icon": {"image": "/images/report_user.png" } }, "Root": { "Valid_children": ["department", "Root"], "icon": {"image": "/images/skysolar_logo.png" }, "Remove":false}}} ). Bind ("Select_node.jstree",function(event, data) {if(Data.rslt.obj.attr ("id")! =undefined) { varURL =window.location.href.toLowerCase (); varid = data.rslt.obj.attr ("id"). toString (); }})//CreateNode. Bind ("Create.jstree",function(E, data) {varCreatedata = "{"; Createdata+ = ' "Organizename": "' + data.rslt.name + '" '; Createdata+ = ', "parentid": ' + parseint (data.rslt.parent.attr ("id"). Replace ("Li_", "")); Createdata+= "}"; $.ajax ({type:"POST", URL:"/wcf/userservice.svc/addorganization", ContentType:"Text/json;charset=utf-8", Data:createdata, success:function(data1) {varID =parseint (DATA1.D); $ (data.rslt.obj). attr ("id", "li_" +data1.d); }, Error:function() {alert ("Create Failure."); $.jstree.rollback (DATA.RLBK); } }) })//Remove Node. Bind ("Remove.jstree",function(E, data) {Data.rslt.obj.each (function () { varRemovedata = ' {' ids ': ' + This. Id.replace ("Li_", "") + '} '; $.ajax ({type:"POST", URL:"/wcf/userservice.svc/deleteorganize", ContentType:"Text/json;charset=utf-8", Data:removedata, success:function(r) {alert (R.D); if(R.D! = "Delete Success") {$.jstree.rollback (DATA.RLBK); }}, Error:function() {alert ("Remove Failure."); $.jstree.rollback (DATA.RLBK); } }); }); }) //Rename. Bind ("Rename.jstree",function(E, data) {varid = parseint (data.rslt.obj.attr ("id"). Replace ("Li_", "" ")); varNewName =Data.rslt.new_name; if(NewName! = "" && newName! =undefined) { varRenamedata = ' {' id ': ' + ID + ', ' newName ': ' + newName + ' '} '; $.ajax ({type:"POST", URL:"/wcf/userservice.svc/renameorganization", ContentType:"Text/json;charset=utf-8", Data:renamedata, success:function(r) {}, Error:function() {$.jstree.rollback (DATA.RLBK); } }); } }) //Move. Bind ("Move_node.jstree",function(E, data) {Data.rslt.o.each (function(i) {varid = parseint ( This. Id.replace ("Li_", "" ")); varNewparentid = 0; if(Data.rslt.np.attr ("id")! = "Organizediv") {Newparentid= parseint (data.rslt.np.attr ("id"). Replace ("Li_", "" ")); } varindex = parseint ($ ("#" + This. ID). Parent (). Children (). Index ($ ("#" + This. ID))); varMovedata = ' {' + ' "id": ' + ID + ', ' newparentid ': ' + Newparentid + ', ' index ': ' + Index + '} '; $.ajax ({type:"POST", URL:"/wcf/userservice.svc/sortorganize", ContentType:"Text/json;charset=utf-8", Data:movedata, success:function(r) {}, Error:function() {alert ("Move Failure."); $.jstree.rollback (DATA.RLBK); } }); }); });
"Jstree" Jstree using the API