easyui tab
2015-11-04 15:02
477 查看
//在当前页面打开一个子tab parent.addChildTab(title, url, ''); //在当前页面关闭打开的子tab parent.closeChildTab();
// 初始化菜单栏 function initMenu(menu) { var result = eval("(" + menu + ")"); var data = result.data[0].children; if (data.length == 0) { self.location = "/logout.jsp"; return; } // 加载菜单栏 for ( var i = 0; i < data.length; i++) { var content = "<div style='margin: 10px;'>"; if(data[i].leaf == true){ content += "<div style='margin: 5px;'><a href='#' onclick=\"javascript: addTab('" + data[i].name + "', '" + data[i].value.replace("(.*)", "list") + "');\">" + data[i].name + "</a></div>"; }else{ for (var j = 0; j < data[i].children.length; j++) { if (data[i].children[j].leaf==false){ var s=data[i].children[j]; fun(s,1,s.id); content=$("#treeValue").html(); }else{ content += "<div style='margin: 5px;'><a href='#' onclick=\"javascript: addTab('" + data[i].children[j].name + "', '" + data[i].children[j].value.replace("(.*)", "list") + "');\">" + data[i].children[j].name + "</a></div>"; } } } $("#treeValue").html(""); $("#temporaryValue").html(""); content += "</div>"; var openFlag = false; if(data[i].name == "我的工作"){ openFlag = true; } $("#manage-console").accordion("add", { id : data[i].value, title : data[i].name, content : content, selected : openFlag }); } addChildTab("待办任务",'/task/do/list.htm'); } function fun(obj,flag,id){ var treeContext=""; treeContext+="<ul class='easyui-tree' id='temporaryId"+id+"'>"; treeContext+="</ul>"; var temporaryContext=""; $(obj).each(function(x,y){ if (y.leaf==false){ temporaryContext+='<li id="liId'+y.id+'">'; temporaryContext+="<span id='span"+y.id+"'>"+y.name+"</span>"; temporaryContext+="<ul id='ulId"+y.id+"'>"; temporaryContext+="</ul>"; temporaryContext+="</li>"; if(flag==1){ $("#temporaryValue").html(treeContext); $("#temporaryId"+y.id+"").append(temporaryContext); var valueHtml=$("#treeValue").html(); $("#treeValue").html(valueHtml+=$("#temporaryValue").html()); $("#liId"+id+"").attr("data-options","state:'closed'"); }else{ $("#ulId"+id+"").append(temporaryContext); $("#liId"+y.id+"").attr("data-options","state:'closed'"); } fun(y.children,2,y.id); }else{ var valueContext=""; valueContext+="<li>"; valueContext+="<span><a href='#' onclick=\"javascript: addTab('" + y.name + "', '" + y.value.replace("(.*)", "list") + "');\">" + y.name + "</a></span>"; valueContext+="</li>"; $("#ulId"+id+"").append(valueContext); } }) } // 打开Tab页 function addTab(title, uri) { if(uri.indexOf("_") == 0) window.open(uri.substring(1)); else { $("#manage-tabs").tabs("close", title); uri += uri.indexOf("?") > -1 ? "&" : "?"; uri += "rand=" + Math.random(); $("#manage-tabs").tabs("add", { title : title, content : "<iframe scrolling='auto' src='" + uri + "' frameborder='0' style='width:100%; height:100%;'></iframe>", closable : true }); } } //打开子Tab页 function addChildTab(title, uri, parent) { $("#manage-tabs").tabs("close", title); uri += uri.indexOf("?") > -1 ? "&" : "?"; uri += "rand=" + Math.random(); $("#manage-tabs").tabs("add", { id : parent + "-" + title, title : title, content : "<iframe scrolling='auto' src='" + uri + "' frameborder='0' style='width:100%; height:100%;'></iframe>", closable : true }); } //关闭Tab页 function closeTab() { var tabs = $("#manage-tabs").tabs("getSelected"); $('#manage-tabs').tabs('close', tabs.panel("options").title); } //关闭子Tab页 function closeChildTab() { var tabs = $("#manage-tabs").tabs("getSelected"); $("#manage-tabs").tabs("select", tabs.panel("options").id.split("-")[0]); var parentTab = $("#manage-tabs").tabs("getSelected"); var iframe = parentTab.find("iframe")[0]; var search = iframe.contentWindow.location.search; var href = iframe.contentWindow.location.href.replace(/#/g,"") + (search == "" ? "?" : "&") + "rand=" + Math.random(); iframe.contentWindow.location.replace(href); $("#manage-tabs").tabs("close", tabs.panel("options").title); } //关闭子Tab页(刷新父页iframe) function closeChildTabIframe() { var tabs = $("#manage-tabs").tabs("getSelected"); $("#manage-tabs").tabs("select", tabs.panel("options").id.split("-")[0]); var parentTab = $("#manage-tabs").tabs("getSelected"); var iframe = parentTab.find("iframe")[0]; var search = iframe.contentWindow.right.location.search; var href = iframe.contentWindow.right.location.href.replace(/#/g,"") + (search == "" ? "?" : "&") + "rand=" + Math.random(); iframe.contentWindow.right.location.replace(href); $("#manage-tabs").tabs("close", tabs.panel("options").title); }
相关文章推荐
- iOS之获取UITableViewCell中UITextField的值方法总结
- UICollectionView(相册大图查看)
- Error: Program "C:\android\android-ndk-r10\ndk-build.cmd" not found in PATH
- UILabel (API+自定义多颜色文本内容)
- 3538: [Usaco2014 Open]Dueling GPS
- 基于QtQuick的二维码解码
- UITableView的cell一些设置
- iOS开发UITableViewCell滚动到特定的行数
- UI界面设计嘚吧嘚
- UILabel自适应高度和自动换行
- [leetcode] 96. Unique Binary Search Trees 解题报告
- 将UIview的image保存到本地的方法
- Request的getParameter和getAttribute方法的区别
- [Ocean Modelling for Begineers] Ch3. Basics of Geophysical Fluid Dynamics
- iOS小技巧-UITableView取消或设置cell的选中效果
- UISearchController的用法,搜索后点击进入下一页要特别注意 [self.searchController presentViewController:detailVC animated
- HDU 4441 【Splay】 Queue Sequence
- UIPageControl分页控件
- 由ligerUI到amazeUI+dataTable插件
- UIScrolloView的简单用法