jquery Tree Plugin dynatree Wrapper object

Source: Internet
Author: User

This is the jquery Dynatree plugin wrapper object, made some improvements and enhancements, added the right-click menu, and the corresponding events and other extensions
1. [Basic use of Code]magicdtree

<script type=text/javascript>
$ (function () {
var Ctxmenu = $ (' #ctxMenu1 ');
var tree = $ (' #tree1 ');
Tree.mac (' Dtree ', {
Treeconfig: {
Title:Msg.region.allRegions,
Rootvisible:true
},
Ctxmenu:ctxmenu,
Doinsert:function (DT, callback) {
var d = dt.data;
D.level = d.level?d.level:0;
var p = {level:1, path: '/', Parent: ' Root '};
if (d.level>0) {
P.parent = D.key;
P.level = D.level + 1;
if (d.level==1) {
P.path = '/' + D.key + '/';
}else{
P.path = D.path + D.key + '/';
}
P.value = D.value;
}
App.open ({
Action: ' Editregion ',
Title:Msg.region.add,
Modal:true,
Params:p
}, Function (dd) {
Callback (DD);
Dt.deactivate ();
Dt.activate ();
});
},
Doupdate:function (DT, callback) {
var d = dt.data;
App.open ({
Action: ' Editregion ',
Title: ' Msg.region.edit ',
Modal:true,
Params:d
}, Function (dd) {
Callback (DD);
});
},
Dodelete:function (DT, callback) {
Mac.confirm (' Msg.confirm.message ', function () {
Mac.alert (' Delete is not allowed in this demo. ')
var p = {id:dt.data.key, level:dt.data.level};
$.post (' delete.php ', p, function (data) {
var ro = mac.eval (data);
if (ro.success) {
Mac.alert (Msg.info.success, [Msg.del]);
Callback ();
var tx = Tree.getnode (dt.data.parent);
Tx.activate (); WordArt
}else{http://www.huiyi8.com/yishuzi/?
Mac.alert (Ro.data, ro.params);
//                  }
//              });
}, [' Msg.del ']);
},
Loader: {
URL: '/javascript/dtree/list.php ',
Params: {key: ' Root '},
Autoload:true
},
Onctxmenu:function (EL) {
var d = el.prop (' Dtnode '). Data;
Ctxmenu.enablecontextmenuitems ();
if (!d.level) {
Ctxmenu.disablecontextmenuitems (' Update,delete ');
}
}
});
$ ('. Demosource '). Val ($ (' #demo '). html ());
Mac.setlanguage ();
});
</SCRIPT>

<div id=tree1></div>
<ul id=ctxmenu1 class= "Ctxmenu" >
<li class= "Add Item Clear" action= "Insert" ><span ><span class= "icon Icon-plus" ></SPAN>< Span>add region</span> </SPAN></LI>
<li class= "Edit Item Clear" action= "Update" ><span ><span class= "icon Icon-pencil" ></SPAN>< Span>edit region</span> </SPAN></LI>
<li class= "Delete Item clear" action= "delete" ><span ><span class= "icon Icon-minus" ></SPAN> <span>delete region</span> </SPAN></LI></UL>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.