点击左边的菜单在右边的tab中打开。其实easyui要实现这种布局很简单,只需要简单的几行代码就ok了。
特意做了一个小小的demo供大家参考,还把怎么实现tab的右键菜单附上。
效果图:
源码:
js部分:
$( function () {
// 动态菜单数据
var treeData = [{
text : "菜单",
children : [{
text : "一级菜单1",
attributes : {
url : ""
}
}, {
text : "一级菜单2",
attributes : {
url : ""
}
}, {
text : "一级菜单3",
state : "closed",
children : [{
text : "二级菜单1",
attributes : {
url : ""
}
}, {
text : "二级菜单2",
attributes : {
url : ""
}
}, {
text : "二级菜单3",
attributes : {
url : ""
}
}
]
}
]
}
];
// 实例化树形菜单
$("#tree").tree({
data : treeData,
lines : true,
onClick : function (node) {
if (node.attributes) {
Open(node.text, node.attributes.url);
}
}
});
// 在右边center区域打开菜单,新增tab
function Open(text, url) {
if ($("#tabs").tabs('exists', text)) {
$('#tabs').tabs('select', text);
} else {
$('#tabs').tabs('add', {
title : text,
closable : true,
content : text
});
}
}
// 绑定tabs的右键菜单
$("#tabs").tabs({
onContextMenu : function (e, title) {
e.preventDefault();
$('#tabsMenu').menu('show', {
left : e.pageX,
top : e.pageY
}).data("tabTitle", title);
}
});
// 实例化menu的onClick事件
$("#tabsMenu").menu({
onClick : function (item) {
CloseTab( this, item.name);
}
});
// 几个关闭事件的实现
function CloseTab(menu, type) {
var curTabTitle = $(menu).data("tabTitle");
var tabs = $("#tabs");
if (type === "close") {
tabs.tabs("close", curTabTitle);
return;
}
var allTabs = tabs.tabs("tabs");
var closeTabsTitle = [];
$.each(allTabs, function () {
var opt = $( this).panel("options");
if (opt.closable && opt.title != curTabTitle && type === "Other") {
closeTabsTitle.push(opt.title);
} else if (opt.closable && type === "All") {
closeTabsTitle.push(opt.title);
}
});
for ( var i = 0; i < closeTabsTitle.length; i++) {
tabs.tabs("close", closeTabsTitle[i]);
}
}
// 动态菜单数据
var treeData = [{
text : "菜单",
children : [{
text : "一级菜单1",
attributes : {
url : ""
}
}, {
text : "一级菜单2",
attributes : {
url : ""
}
}, {
text : "一级菜单3",
state : "closed",
children : [{
text : "二级菜单1",
attributes : {
url : ""
}
}, {
text : "二级菜单2",
attributes : {
url : ""
}
}, {
text : "二级菜单3",
attributes : {
url : ""
}
}
]
}
]
}
];
// 实例化树形菜单
$("#tree").tree({
data : treeData,
lines : true,
onClick : function (node) {
if (node.attributes) {
Open(node.text, node.attributes.url);
}
}
});
// 在右边center区域打开菜单,新增tab
function Open(text, url) {
if ($("#tabs").tabs('exists', text)) {
$('#tabs').tabs('select', text);
} else {
$('#tabs').tabs('add', {
title : text,
closable : true,
content : text
});
}
}
// 绑定tabs的右键菜单
$("#tabs").tabs({
onContextMenu : function (e, title) {
e.preventDefault();
$('#tabsMenu').menu('show', {
left : e.pageX,
top : e.pageY
}).data("tabTitle", title);
}
});
// 实例化menu的onClick事件
$("#tabsMenu").menu({
onClick : function (item) {
CloseTab( this, item.name);
}
});
// 几个关闭事件的实现
function CloseTab(menu, type) {
var curTabTitle = $(menu).data("tabTitle");
var tabs = $("#tabs");
if (type === "close") {
tabs.tabs("close", curTabTitle);
return;
}
var allTabs = tabs.tabs("tabs");
var closeTabsTitle = [];
$.each(allTabs, function () {
var opt = $( this).panel("options");
if (opt.closable && opt.title != curTabTitle && type === "Other") {
closeTabsTitle.push(opt.title);
} else if (opt.closable && type === "All") {
closeTabsTitle.push(opt.title);
}
});
for ( var i = 0; i < closeTabsTitle.length; i++) {
tabs.tabs("close", closeTabsTitle[i]);
}
}
html部分:
<! DOCTYPE html >
< html >
< head >
< meta charset =utf-8 />
< title >JS Bin </ title >
< script class ="jsbin" src ="http://code.jquery.com/jquery-1.7.2.min.js" ></ script >
< link rel ="stylesheet" type ="text/css" href ="http://www.jeasyui.com/easyui/themes/default/easyui.css" >
< script type ="text/javascript" src ="http://www.jeasyui.com/easyui/jquery.easyui.min.js" ></ script >
<!-- [if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif] -->
< style >
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
.west{
width: 200px;
padding: 10px;
}
.north{
height: 100px;
}
</ style >
</ head >
< body class ="easyui-layout" >
< div region ="north" class ="north" title ="____′↘夏悸 http://easyui.btboys.com" >
< h1 >最简单的左右结构实现,及tab的右键菜单实现,右键查看源码 </ h1 >
</ div >
< div region ="center" title ="center" >
< div class ="easyui-tabs" fit ="true" border ="false" id ="tabs" >
< div title ="首页" ></ div >
</ div >
</ div >
< div region ="west" class ="west" title ="menu" >
< ul id ="tree" ></ ul >
</ div >
< div id ="tabsMenu" class ="easyui-menu" style ="width:120px;" >
< div name ="close" >关闭 </ div >
< div name ="Other" >关闭其他 </ div >
< div name ="All" >关闭所有 </ div >
</ div >
</ body >
< html >
< head >
< meta charset =utf-8 />
< title >JS Bin </ title >
< script class ="jsbin" src ="http://code.jquery.com/jquery-1.7.2.min.js" ></ script >
< link rel ="stylesheet" type ="text/css" href ="http://www.jeasyui.com/easyui/themes/default/easyui.css" >
< script type ="text/javascript" src ="http://www.jeasyui.com/easyui/jquery.easyui.min.js" ></ script >
<!-- [if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif] -->
< style >
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
.west{
width: 200px;
padding: 10px;
}
.north{
height: 100px;
}
</ style >
</ head >
< body class ="easyui-layout" >
< div region ="north" class ="north" title ="____′↘夏悸 http://easyui.btboys.com" >
< h1 >最简单的左右结构实现,及tab的右键菜单实现,右键查看源码 </ h1 >
</ div >
< div region ="center" title ="center" >
< div class ="easyui-tabs" fit ="true" border ="false" id ="tabs" >
< div title ="首页" ></ div >
</ div >
</ div >
< div region ="west" class ="west" title ="menu" >
< ul id ="tree" ></ ul >
</ div >
< div id ="tabsMenu" class ="easyui-menu" style ="width:120px;" >
< div name ="close" >关闭 </ div >
< div name ="Other" >关闭其他 </ div >
< div name ="All" >关闭所有 </ div >
</ div >
</ body >
</html>
相关推荐
jquery easyui 经典布局 类似extjs 感谢原作者
一个很不错的关于jQuery EasyUI入门学习的Demo。涉及界面的布局排版、数据的动态加载、窗口的自适应等方面。特别地,该实例通过对界面模块的合理划分、js脚本的动态引用以及css样式的渲染等操作完成。注:例子中,所...
jQueryEasyUI是目前JavaWeb领域流行的插件开发工具。《jQueryEasyUI开发指南》主要讲述EasyUI各种插件的用法以及前端插件开发思想,带领读者走入插件开发的世界。在本书中,读者不但可以学到搜索框(searchbox)、...
jQuery EasyUI 仿 Extjs 界面布局,左边手风琴折叠菜单。点击菜单在右边content区域可增加tab标签,可作为项目的main页
本 chm 文档是根据博客园“风流涕淌”的《jQuery EasyUI 1.2.4 API 中文文档(完整)目录》整理而成 http://www.cnblogs.com/Philoo/archive/2011/11/17/jeasyui_api_index.html Base 基础 Documentation 文档 ...
1. 该框架的开发环境为EclipseJEE集成开发工具。... 前台展示页面使用了JQuery EasyUI的布局、列表和消息组件。 6. 系统实现了较为完善的用户模块,对用户数据实现了增、删、改、查、分页等的功能。
jQuery EasyUI 是一个基于 jQuery 的框架,集成了各种用户界面插件。接下来通过本文给大家介绍jQuery Easyui实现左右布局,涉及到到easyui左右布局相关知识,感兴趣的朋友一起学习吧
jQuery EasyUI 1.3.5版本更新内容: Bug(修复) searchbox:修复“searcher”函数提供的“name”参数值错误的问题; combo:修复“isValid”方法无法返回布尔值的问题; combo:修复点击页面某一个combo组件的...
easyui是一个基于jquery的集成了各种用户界面的插件。 使用easyui你不需要写太多javascript代码,一般情况下你只...jQuery easyui 为网页开发提供了一堆的常用UI组件,包括菜单、对话框、布局、窗帘、表格、表单等等
jQuery EasyUI Layout是一种基于jQuery的布局框架,今天初次使用Jquery EasyUi,简单的做了个布局页面感觉还不错,特此分享脚本之家平台供大家学习
jQuery easyui后台管理页面tab布局样式代码
jQuery EasyUI为网页开发提供了一堆的常用UI组件,包括菜单、对话框、布局、窗帘、表格、表单等等逐渐。
jQuery EasyUI源码、demo合集、离线api、个性化的layout布局!
使用jquery-easyui框架搭建用户界面自定义布局
单表的增删该查,jqueryeasyui 布局,分页,
jQuery easyUI 培训 教程 1 Accordion(可折叠标签) 2 1.1 实例 2 1.2 参数 3 2 DateBox(日期框) 4 2.1 实例 4 2.2 参数 6 2.3 事件 6 2.4 方法 6 3 ComboBox(组合框) 7 3.1 实例 7 3.2 参数 9 3.3 事件 9 3.4 ...
jquery easyui 布局小例子。 easyui :实现Tab页面 Jqueryui + easywidgets 实现可拖动个性化页面 左侧类似淘宝商城菜单使用css实现 点击菜单,在新tab页中显示新页面...
本文给大家介绍jquery easyui布局之动态添加tabs标签页,实现思路是这样的通过调用add方法就可以轻松实现,本文分步骤给大家详细介绍,需要的朋友一起学习吧
jquery easyui min 使用它来布局个人觉得还是很好