jstree 使用API

jstree 使用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) { var Url = window.location.href.toLowerCase(); var id = data.rslt.obj.attr("id").toString(); } }) //createnode .bind("create.jstree", function (e, data) { var createdata = "{"; 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) { var id = 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 () { var removedata = '{"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) { var id = parseInt(data.rslt.obj.attr("id").replace("li_", "")); var newName = data.rslt.new_name; if (newName != "" && newName != undefined) { var renamedata = '{"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) { var id = parseInt(this.id.replace("li_", "")); var newparentid = 0; if (data.rslt.np.attr("id") != "Organizediv") { newparentid = parseInt(data.rslt.np.attr("id").replace("li_", "")); } var index = parseInt($("#" + this.id).parent().children().index($("#" + this.id))); var movedata = '{' + '"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); } }); }); });
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值