Jquery EasyUI后台实例
原文作者:http://www.cnblogs.com/sobne/articles/1865532.html
什么都不说,先放效果:
首先是一个布局
左边是个Accordion
右边主要区域是Tabs
还有个例子很典型的左右结构:左边树(Tree),右边表格(datagrid)
ok,代码如下:
1.主页代码
<</SPAN>head>
<</SPAN>title></</SPAN>title>
<</SPAN>link href="js/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<</SPAN>link href="js/themes/icon.css" rel="stylesheet" type="text/css" />
<</SPAN>script src="js/jquery-1.4.2.min.js" type="text/javascript"></</SPAN>script>
<</SPAN>script src="js/jquery.easyui.min.js" type="text/javascript"></</SPAN>script>
<</SPAN>script src="Default.js" type="text/javascript"></</SPAN>script>
<</SPAN>style type="text/css">
.easyui-accordion ul
{
list-style-type: none;
margin: 0px;
padding: 10px;
}
.easyui-accordion ul li
{
padding: 0px;
}
.easyui-accordion ul li a
{
line-height: 24px;
}
.easyui-accordion ul li div
{
margin: 2px 0px;
padding-left: 10px;
padding-top: 2px;
}
.easyui-accordion ul li div.hover
{
border: 1px dashed #99BBE8;
background: #E0ECFF;
cursor: pointer;
}
.easyui-accordion ul li div.hover a
{
color: #416AA3;
}
.easyui-accordion ul li div.selected
{
border: 1px solid #99BBE8;
background: #E0ECFF;
cursor: default;
}
.easyui-accordion ul li div.selected a
{
color: #416AA3;
font-weight: bold;
}
</</SPAN>style>
</</SPAN>head>
<</SPAN>body class="easyui-layout" style="overflow-y: hidden" scroll="no">
<</SPAN>noscript>
<</SPAN>div style="position: absolute; z-index: 100000; height: 2046px; top: 0px; left: 0px;
width: 100%; background: white; text-align: center;">
<</SPAN>img src="images/noscript.gif" alt='抱歉,请开启脚本支持!' />
</</SPAN>div>
</</SPAN>noscript>
<</SPAN>div region="north" split="true" style="overflow: hidden; height: 30px; background: #D2E0F2 repeat-x center 50%;
line-height: 20px; color: #fff;">
欢迎使用
</</SPAN>div>
<</SPAN>div region="south" style="height: 20px; background: #D2E0F2;">
<</SPAN>div style="text-align: center; font-weight: bold">
EntWebSite ver 1.0</</SPAN>div>
</</SPAN>div>
<</SPAN>div region="west" split="true" title="导航菜单" style="width: 180px;overflow:hidden;" icon="icon-redo">
<</SPAN>div id="menu" class="easyui-accordion" fit="true" border="false">
<</SPAN>div title="系统管理" style="overflow:auto; padding: 10px;" icon="icon-edit">
<</SPAN>div title="网站设置">
<</SPAN>ul>
<</SPAN>li>
<</SPAN>div>
<</SPAN>a target="mainFrame" href="Product/Default.htm">网站设置</</SPAN>a></</SPAN>div>
</</SPAN>li>
</</SPAN>ul>
</</SPAN>div>
</</SPAN>div>
<</SPAN>div title="产品管理" style="padding: 10px;" icon="icon-edit">
<</SPAN>div title="产品管理">
<</SPAN>ul>
<</SPAN>li>
<</SPAN>div>
<</SPAN>a target="mainFrame" href="Product/Default.htm">产品管理</</SPAN>a></</SPAN>div>
</</SPAN>li>
</</SPAN>ul>
</</SPAN>div>
</</SPAN>div>
<</SPAN>div title="关于" icon="icon-help">
<</SPAN>h4>
EntWebSite Ver 1.0</</SPAN>h4>
</</SPAN>div>
</</SPAN>div>
</</SPAN>div>
<</SPAN>div region="center" id="mainPanle" style="background: #eee;overflow:hidden;">
<</SPAN>div id="tabs" class="easyui-tabs" fit="true" border="false">
<</SPAN>div title="主页" style="padding: 20px;" id="home">
<</SPAN>h1>
Welcome...</</SPAN>h1>
</</SPAN>div>
</</SPAN>div>
</</SPAN>div>
</</SPAN>body>
其中Default.js代码如下:
$(function () {
InitLeftMenu();
$('body').layout();
})
function InitLeftMenu() {
$('.easyui-accordion li a').click(function () {
var tabTitle = $(this).text();
var url = $(this).attr("href");
addTab(tabTitle, url);
$('.easyui-accordion li div').removeClass("selected");
$(this).parent().addClass("selected");
}).hover(function () {
$(this).parent().addClass("hover");
}, function () {
$(this).parent().removeClass("hover");
});
}
function addTab(subtitle, url) {
if (!$('#tabs').tabs('exists', subtitle)) {
$('#tabs').tabs('add', {
title: subtitle,
content: createFrame(url),
closable: true,
width: $('#mainPanle').width() - 10,
height: $('#mainPanle').height() - 26
});
} else {
$('#tabs').tabs('select', subtitle);
}
}
function createFrame(url) {
var s = '';
return s;
}