MzTreeView应用

<!-- Json 循环列出树形菜单 注意点:tree.nodes[]中键不可加引号 -->
<script type="text/javascript">
var tree = new MzTreeView("tree");
tree.icons["property"] = "property.gif";
tree.icons["css"] = "collection.gif";
tree.icons["event"] = "collection.gif";
tree.icons["book"] = "book.gif";
tree.iconsExpand["book"] = "bookopen.gif";
tree.setIconPath("/images/treeview/"); //展开时对应的图片的存放路径

tree.nodes["0_1"] = "text:世界;url:/Contract/index";
tree.nodes["1_2"] = "text:中国;url:/Contract/index";
tree.nodes["1_3"] = "text:美国;url:/Contract/index";
tree.nodes["2_5"] = "text:北京;url:/Contract/index";
tree.nodes["2_6"] = "text:天津;url:/Contract/index";
tree.nodes["2_7"] = "text:上海;url:/Contract/index";
tree.nodes["2_8"] = "text:河北;url:/Contract/index";
tree.nodes["3_9"] = "text:洛杉矶;url:/Contract/index";
tree.nodes["3_10"] = "text:华盛顿;url:/Contract/index";
tree.nodes["5_11"] = "text:海淀;url:/Contract/index";
tree.nodes["5_12"] = "text:朝阳;url:/Contract/index";
tree.nodes["8_13"] = "text:石家庄;url:/Contract/index";
tree.nodes["8_14"] = "text:邯郸;url:/Contract/index";


//var treeList = <?php echo $tree; ?>;
//for(var key in treeList){
// tree.nodes[treeList[key].concate.parent_id + "_" + treeList[key].concate.id] = "text:" + treeList[key].concate.caption + ";url:http://www.baidu.com;target:_blank";
//}
document.write(tree.toString());

</script>

 

 

注意:注意:当用循环Json时,需要注意到tree.nodes[""]中的""是不可用的,否则可能会显示不了!当写数据时,可以这样写:tree.nodes["0_1"] = "text:AAA;url:bbb";但当循环时,例:tree.nodes["'" + treeList[key].concate.parent_id + "_" + treeList[key].concate.id + "'"] = "text:" + treeList[key].concate.caption + ";url:http://www.baidu.com;target:_blank";这种不可取。"'"不能写。

最后效果:如下图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值