jquery easyui dialog 有一个onLoad方法,在远程加载时调用,我们利用这个解决该问题。
在调用的那个父页面上书写所用的js方法,子页面上只有<body>内容即可:
实例:
子页面:
<html>
<head>
<base href="${ctx }">
<title>My JSP 'addOrEditPersonalArticle.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<center>
<form id="personalForm">
<table bordercolor="#121010" border="1" cellpadding="0" cellspacing="0" width="700px">
<tr>
<td nowrap="nowrap">*文章标题:</td>
<td>
<input type="text" name="title" id="title" value="${article.title }" style="width:450px"/>
<input type="hidden" name="id" id="id" value="${article.id }"/>
</td>
</tr>
<tr>
<td nowrap="nowrap">*是否发布:</td>
<td>
<input type="radio" name="articleStatus" id="articleStatusYes" <c:if test="${article.articleStatus ==3 }">checked="checked"</c:if> value="3"/>是
<input type="radio" name="articleStatus" id="articleStatusNo" <c:if test="${article.articleStatus !=3 and article.articleStatus != null}">checked="checked"</c:if> value="0"/>否
</td>
</tr>
<tr>
<td nowrap="nowrap">*是否置顶:</td>
<td>
<input type="radio" name="top" id="topYes" <c:if test="${article.top ==1 }">checked="checked"</c:if> value="1"/>是
<input type="radio" name="top" id="topNo" <c:if test="${article.top ==0 }">checked="checked"</c:if> value="0"/>否
</td>
</tr>
<tr align="center">
<td colspan="2">
<textarea name="content" id="content">${article.content }</textarea>
</td>
</tr>
<tr>
<td>备注:</td>
<td>
<textarea name="" style="width: 500px"></textarea>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
父页面:
<html>
<head>
<base href="${ctx}">
<title>My JSP 'personalArticleList.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<script type="text/javascript" src="${ctx}/jsp/resource/js/ckeditor3.6.2/ckeditor.js"></script>
<script type="text/javascript" src="${ctx}/jsp/resource/js/ckfinder/ckfinder.js"></script>
<%@ include file="/jsp/include/resource.jsp"%>
<script>
//新增Or修改个人专栏文章
function addOrEditPersonalArticle(index,id,obj){
$("#addArticleDiv").dialog({
title: '新增文章',
width: 900,
height: 500,
closed: false,
cache: false,
href: '${ctx}/toAddOrEditPersonalArticleView.do?id='+id,
modal: true,
toolbar:[{
text:'保存',
iconCls:'icon-edit',
handler:function(){
alert($("input[name='articleStatus']:checked").val());
if($("#title").val()==null||$("#title").val()==''){
$.messager.alert('提示框','文章标题不能为空!');
return ;
}else if($("input[name='articleStatus']:checked").val()==null||$("input[name='articleStatus']:checked").val()==''){
$.messager.alert('提示框','是否发布不能为空!');
return ;
}else if($("input[name='top']:checked").val()==null||$("input[name='top']:checked").val()==''){
$.messager.alert('提示框','是否置顶不能为空!');
return ;
}
$("#content").val(CKEDITOR.instances.content.getData());
$.ajax({
url:'${ctx}/savePersonalArticle.json',
type:'post',
data:$("#personalForm").serialize(),
dataType:'json',
success:function(data){
$.messager.alert('提示框',data.message);
$("#addArticleDiv").dialog('close');
$("#dg").datagrid("loadData",data);
}
});
}
},{
text:'返回',
iconCls:'icon-edit',
handler:function(){
//window.location.href="${ctx}/findPersonalArticleListView.do";
$("#addArticleDiv").dialog('close');
}
},{
text:'批量替换图片',
iconCls:'icon-edit',
handler:function(){
replacePic();
}
}],
onLoad:function(){
var editor = null;
editor = CKEDITOR.replace( 'content', {
customConfig:'${ctx}/jsp/resource/js/ckeditor3.6.2/config.js'
});
CKFinder.setupCKEditor( editor, '${ctx}/jsp/resource/js/ckfinder/' );
}
});
}
</script>
</head>
<body>
<div >
<!-- 查询和按钮框 -->
<table width="95%">
<tr align="right">
<td><input type="button" οnclick="addOrEditPersonalArticle(null,null,null)" value="新增个人文章"/></td>
</tr>
</table>
</div>
<div >
<!-- 个人放置的内容 -->
<table id="dg">
</table>
<div id="addArticleDiv"></div>
</div>
</body>
</html>