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>