今天你学习了吗?本篇讲述了导航如何生成
//系统时间显示
setInterval("document.getElementById('nowTime').innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
var setting = {
data: {
simpleData: {
enable: true
}
},
view: {
selectedMulti: false
},
callback: {
onClick:function(e, id, node){
var zTree = $.fn.zTree.getZTreeObj("menuTree");
if(node.isParent) {
zTree.expandNode();
} else {
addTabs(node.name, node.file);
}
}
}
};
var zNodes =[//导航的关键代码
{ id:1, pId:0, name:"用户管理", open:false},
{ id:11, pId:1, name:"用户列表", file:"../User/user_retrieve1"},
{ id:2, pId:0, name:"权限管理", open:true},
{ id:21, pId:2, name:"权限列表", file:"../Role/role_retrieve1"}
];
$(function() {
$.fn.zTree.init($("#menuTree"), setting, zNodes);
var zTree = $.fn.zTree.getZTreeObj("menuTree");
//中间部分tab
$('#tabs').tabs({
border:false,
fit:true,
onSelect: function(title, index){
var treeNode = zTree.getNodeByParam("name", title, null);
zTree.selectNode(treeNode);
}
});
$('.index_panel').panel({
width:300,
height:200,
closable:true,
minimizable:true,
title: 'My Panel'
});
});
//添加一个选项卡面板
function addTabs(title, url, icon){
if(!$('#tabs').tabs('exists', title)){
$('#tabs').tabs('add',{
title:title,
content:'<iframe src="'+url+'" frameBorder="0" border="0" scrolling="no" style="width: 100%; height: 100%;"/>',
closable:true
});
} else {
$('#tabs').tabs('select', title);
}
}