1.layer引入
1 <script src="../../Scripts/jquery.min.1.9.1.js" type="text/javascript"></script> 2 <script src="../../Scripts/common.js" type="text/javascript"></script> 3 <script src="../../Scripts/layer-v2.2/layer/layer.js" type="text/javascript"></script> 4 <link href="../../Scripts/layer-v2.2/layer/skin/layer.css" rel="stylesheet" />
2.弹窗
1 /*************主题与模板弹窗***************/ 2 var num = 0; 3 function ShowThemeTempnExus() 4 { 5 layer.open({ 6 type: 2, 7 id: 'framTheme',//只允许弹出一个 8 title: '主题与模板', 9 area: ['618px', '417px'], 10 fixed: false, //不固定 11 maxmin: true,//最大最小化 12 content: '/Admin/COM/ThemeTempnExusList.aspx', 13 btn: ['确定', '取消'], 14 yes: function (index, layero) { 15 var body = layer.getChildFrame('body', index); 16 var iframeWin = window[layero.find('iframe')[0]['framTheme']]; 17 var strThemeId = body.find('input:radio[name="themeID"]:checked').val(); 18 var strThemeName = body.find('input:radio[name="themeID"]:checked').next("span").text(); 19 var strReadNum = body.find('input:radio[name="userConfigID"]:checked').val(); 20 var strUserConfigName = body.find('input:radio[name="userConfigID"]:checked').next("span").text(); 21 var strIsDefatult = body.find('input:radio[name="IsDefault"]:checked').val() == "1" ? "是" : "否"; 22 23 var flag = 0, def = 0; 24 $("#dataThemeTempTable tbody tr").each(function () { 25 //主题ID与模板配置编号都相同时,不能重复添加 26 if ($.trim($(this).find("td").eq(2).html()) == $.trim(strThemeId) && $.trim($(this).find("td").eq(5).html()) == $.trim(strReadNum)) { 27 flag = 1; 28 } 29 //默认模板与主题,只能有一个 30 if ($.trim($(this).find("td").eq(6).html()) == $.trim("是") && $.trim(strIsDefatult) == $.trim("是")) { 31 def = 1; 32 } 33 }); 34 if (flag == 0 && def == 0) {//去重复 35 if (strThemeName != "" && strUserConfigName != "") { 36 num++; 37 var ww = $("#dataThemeTempTable tbody"); 38 var img = '<img src="../../Images/delete.png" alt="删除" id="imdDel0" name="imdDel0" onclick="DelUtm(this,0)" />'; 39 ww.append("<tr><td>" + img + "</td><td>" + num + "<td>" + strThemeId + "</td><td>" + strThemeName + "</td><td>" + strUserConfigName + "</td><td>" + strReadNum + "</td><td>" + strIsDefatult + "</td></tr>"); 40 } 41 } 42 layer.close(index); 43 }, btn2: function (index, layero) { 44 layer.close(index); 45 } 46 }); 47 }
3.调用
1 <table class="tableborderdetail" border="1" id="dataThemeTempTable"> 2 <thead><tr style="background-color: #edf1fa;"> 3 <td class="detailsImg"> 4 <img src="../../Images/Glyph-Add.png" onclick="ShowThemeTempnExus()" alt="" /><input 5 type="hidden" id="hisContractResponsible" value="" /> 6 </td> 7 <td class="rowNum" nowrap="nowrap">序号</td><td>主题ID</td><td>主题名称</td><td>模板名称</td><td>模板配置编号</td><td>是否默认</td> 8 </tr></thead> 9 <tbody></tbody> 10 </table>
4.删除行
1 //删除主题与模板配置关系行 2 function DelUtm(obj, id) { 3 num--;//序号 4 var trs = $(obj).parent("td").parent("tr"); 5 $(trs).remove(); 6 }