easyUI accordion 使用和remove方法 for循环的异常
2017-06-06 16:03
357 查看
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/WEB-INF/jsp/common/taglib.jsp"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <%@ include file="/WEB-INF/jsp/common/easyUi.jsp"%> </head> <body class="easyui-layout"> <div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:10px"> <ul class="nav nav-pills navbar-pos"> <li role="presentation"><a href="#" path="index/home" datatype="system">系统管理</a></li> <li role="presentation"><a href="#" onclick="logout()">退出登录</a></li> </ul> </div> <div class='sss' data-options="region:'west',split:true,title:'导航菜单'" style="width:150px;padding:0px;"> <div class="easyui-accordion left_options" data-options="fit:true,border:false"> <div title="Title1" style="padding:10px;"> content1 </div> <div title="Title2" data-options="selected:true" style="padding:10px;"> content2 </div> <div title="Title3" style="padding:10px"> content3 </div> </div> </div> <div data-options="region:'east',split:true,collapsed:true,title:'East'" style="width:100px;padding:10px;">east region</div> <div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;">south region</div> <div data-options="region:'center',title:'Center'" style="border:false;overflow: hidden;"> <iframe src="${path}/role/2" id="myIframe" name="myIframe" style="width:100%;height:100%;border:false;overflow: hidden;"></iframe> </div> <script type="text/javascript"> //$(function(){ var system = [ {cname: "组织机构",igclass:"fa",iclass:"fa-users", path:"user", childrens: [ {cname: "用户管理",igclass:"fa",iclass:"fa-users", path:"user", childrens: []}, {cname: "角色管理",igclass:"glyphicon",iclass:"glyphicon-tint", path:"role/2", childrens: []}, {cname: "权限管理",igclass:"glyphicon",iclass:"glyphicon-tint", path:"auth", childrens: []} ]},{cname: "角色机构",igclass:"fa",iclass:"fa-users", path:"user", childrens: [ {cname: "角色管理",igclass:"glyphicon",iclass:"glyphicon-tint", path:"role", childrens: []}, {cname: "权限管理",igclass:"glyphicon",iclass:"glyphicon-tint", path:"auth", childrens: []} ]} ]; //}) $(function(){ }) $(".nav>li").click(function(){ $(this).addClass("active"); $(this).siblings().removeClass("active"); var ask = $(this).attr("accesskey"); var a=$(this).children("a"); var datatype = $(a).attr("datatype"); console.info(datatype); var pnl = $(".left_options").accordion("panels"); var titles=''; if (pnl){ $.each(pnl, function(i) { var title = pnl[i].panel("options").title; titles += title+','; }) } var arr_title = new Array(); arr_title = titles.split(","); for (i=0;i<arr_title.length ;i++ ) { if(arr_title[i] != ""){ $('.left_options').accordion("remove",arr_title[i]); } } left_opt = eval(datatype); html = ''; $.each(left_opt, function(i) { var result = left_opt[i]; if (i == 0) {//显示第一个一级菜单下的二级菜单 $('.left_options').accordion('add', { title : left_opt[i].cname, iconCls : left_opt[i].iclass, selected : true, content : function(){ var children = left_opt[i].childrens; var html = ''; html += '<div class="" style="padding:10px"><ul class="" name="'+left_opt[i].cname+'">'; $.each(children, function(i) { html += '<li><a href="javascript:center_show(\''+children[i].path+'\');" path="'+children[i].path+'">'+children[i].cname+'</a></li>'; }) html += '</ul></div>'; return html; } }); } else { $('.left_options').accordion('add', { title : left_opt[i].cname, iconCls : left_opt[i].iclass, selected : false, content : function(){ var children = left_opt[i].childrens; var html = ''; html += '<sec:authorize ifAllGranted="/role/2"><div class="" style="padding:10px"><ul class="" name="'+left_opt[i].cname+'">'; $.each(children, function(i) { html += '<li><a href="javascript:center_show(\''+children[i].path+'\');" path="'+children[i].path+'">'+children[i].cname+'</a></li>'; }) html += '</ul></div></sec:authorize>'; return html; } }); } }) }); function center_show(url){ document.getElementById("myIframe").src="${pageContext.request.contextPath}/"+url; } function logout(){ window.location.href="${pageContext.request.contextPath}"+"/j_spring_security_logout"; } </script> </body> </html>是在清除titile的时候,不能放在for里面直接删除,所以放在数组里面在循环删除这样能解决掉
相关文章推荐
- ArrayList在for循环中使用remove方法移除元素方法介绍
- 黑马程序员--谨慎使用for循环中的remove(int index)方法
- ArrayList在for循环中使用remove方法移除元素
- 多线程写文件异常(正由另一进程使用,因此该进程无法访问该文件)的解决方法
- 讨论:一个类的方法应该使用返回值来标识执行状态,还是抛出异常?
- 多线程写文件异常(正由另一进程使用,因此该进程无法访问该文件)的解决方法
- 使用JDBC连接DB2时encoding not supported异常的解决方法
- Oracle数据库自定义异常的使用方法
- 使用SQLDMO中“接口SQLDMO.Namelist 的 QueryInterface 失败”异常的解决方法
- 字符串使用replaceAll()方法报异常:Dangling meta character '*' near index 0
- 使用MySQL和Hibernate时,出现java.lang.UnsupportedOperationException: Update queries only supported through HQL异常的解决方法
- Jquery下attr和removeAttr的使用方法
- JComboBox的removeAllItems()方法我遇到的一个异常以及解决
- 使用Oracle连接池错误 Cannot create PoolableConnectionFactory(Io 异常: The Network Adapter could not establish the connection )的解决方法
- 使用SQLDMO中“接口SQLDMO.Namelist 的 QueryInterface 失败”异常的解决方法
- Qt中使用QSqlDatabase::removeDatabase()的正确方法
- Ghost使用中的异常情况及应对方法
- hibernate 使用sessionfactory的getCurrentSession()方法发生异常
- asp.net使用ajax后判断出现异常原因的自定义方法
- Qt中使用QSqlDatabase::removeDatabase()的正确方法