一、创建菜单项
<div class="easyui-accordion" id="wl_accordion" data-options="fit:true,border:false">
<div title="aa" data-options="iconCls:'icon-hamburg-graphic'" style="overflow:auto;">
<ul class="easyui-tree">
<li data-options="iconCls:'icon-hamburg-monitor'"><a href="javascript:;" class="btn_menu" url="aa1url" name="icon-hamburg-monitor">aa1</a></li>
</ul>
</div>
<div title="bb" data-options="iconCls:'icon-hamburg-graphic'" style="overflow:auto;">
<ul class="easyui-tree">
<li data-options="iconCls:'icon-hamburg-monitor'"><a href="javascript:;" class="btn_menu" url="bb1url" name="icon-hamburg-monitor">bb1</a></li>
<li data-options="iconCls:'icon-hamburg-monitor'"><a href="javascript:;" class="btn_menu" url="bb2url" name="icon-hamburg-monitor">bb2</a></li>
</ul>
</div>
</div>
$(".tree-node").click(function () {
var title = $(this).find(".btn_menu").text();
var url = $(this).find(".btn_menu").attr("url");
var icon = $(this).find(".btn_menu").attr("name");
var isSelect = $("#tabs").tabs('exists', title);
var strHtml = '<iframe src="' + url + '" frameborder="0" width="100%" height="100%" marginwidth="0px" marginheight="0px" scrolling="no" style="display:block"></iframe>';
//'exists' 方法来判断 tab 是否已经存在,如果为true,则选中tab
if (isSelect) {
$("#tabs").tabs('select', title);
return;
}else{
$(".tabs li").each(function (index, obj) {
//获取所有可关闭的选项卡
var tab = $(".tabs-closable", this).text();
$(".easyui-tabs").tabs('close', tab);
});
//添加tab菜单
$("#tabs").tabs('add', {
title: title,
content: strHtml,
closable: true,
iconCls: icon,
//刷新按钮
tools: [{
iconCls: 'icon-mini-refresh',
handler: function(){
$('.panel:visible > .panel-body > iframe').get(0).contentDocument.location.reload(true);
}
}]
});
}
});