xheditorの非同期ロードコントロール
5851 ワード
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="js/easyui/themes/icon.css">
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/myjs/easyui.validatebox.extend.js"></script>
<script type="text/javascript" src="js/myjs/easyui.combobox.linkmenu.js"></script>
<style type="text/css">
form{margin: 0}
input[type=text] ,input[type=password]{
width: 200px;
}
select{
width: 205px;
}
a {
border: 0px solid #000;
}
input[type=file]{ width:68px;font-family: ;cursor:pointer;}
</style>
</head>
<body>
<div id="win" class="easyui-window" title=" " data-options="iconCls:'icon-save',maximizable:false,resizable:false" style="width:1000px;height:520px;padding:0 0 10px 0;overflow: hidden;" ></div>
</body>
<script type="text/javascript">
$(function(){
$('#win').window('refresh', 'test3.jsp');
});
function loadJs(){
var communityId = $('#communityId').combobox({
editable:false,
disabled:true,
valueField:'id',
textField:'name',
panelHeight:'auto'
});
var streetId = $('#streetId').combobox({
url:'findByGroupLevel.shtml?groupLevel=2',
editable:false,
valueField:'id',
textField:'name',
panelHeight:'auto',
onSelect:function(record){
// , ,
communityId.combobox({
disabled:false,
url:'findByGroupLevel.shtml?groupLevel=3&pid='+record.id,
valueField:'id',
textField:'name'
}).combobox('clear');
}
});
}
$('#win').window({
onLoad:function(){
initEditor();
}
})
function loadScript (url){
var script = document.createElement ("script");
script.type = "text/javascript";
script.async = true;
script.src = url;
document.body.appendChild (script);
}
function clearForm(){
$('#ff').form('clear');
}
function submitForm(){
$('#ff').form('submit', {
url:"addUserInfo.shtml?t="+new Date().getTime(),
onSubmit: function(){
return $(this).form('validate');
},
success:function(res){
if(res){
$.messager.alert(" "," ");
}else{
$.messager.alert(" "," ");
}
}
});
}
function loadJS(url,callback,charset)
{
var script = document.createElement('script');
script.onload = script.onreadystatechange = function ()
{
if (script && script.readyState && /^(?!(?:loaded|complete)$)/.test(script.readyState)) return;
script.onload = script.onreadystatechange = null;
script.src = '';
script.parentNode.removeChild(script);
script = null;
if(callback)callback();
};
script.charset=charset || document.charset || document.characterSet;
script.src = url;
try {document.getElementsByTagName("head")[0].appendChild(script);} catch (e) {}
}
function initEditor()
{
loadJS("js/xheditor/xheditor-1.2.1.min.js",function(){
loadJS('js/xheditor/xheditor_lang/zh-cn.js');
$('#elm1').xheditor({shortcuts:{'ctrl+enter':submitForm}});
});
}
</script>
</html>
一番大切なのは
<div id="win" class="easyui-window" title=" " data-options="iconCls:'icon-save',maximizable:false,resizable:false" style="width:1000px;height:520px;padding:0 0 10px 0;overflow: hidden;" ></div>
function loadJS(url,callback,charset)
{
var script = document.createElement('script');
script.onload = script.onreadystatechange = function ()
{
if (script && script.readyState && /^(?!(?:loaded|complete)$)/.test(script.readyState)) return;
script.onload = script.onreadystatechange = null;
script.src = '';
script.parentNode.removeChild(script);
script = null;
if(callback)callback();
};
script.charset=charset || document.charset || document.characterSet;
script.src = url;
try {document.getElementsByTagName("head")[0].appendChild(script);} catch (e) {}
}
function initEditor()
{
loadJS("js/xheditor/xheditor-1.2.1.min.js",function(){
loadJS('js/xheditor/xheditor_lang/zh-cn.js');
$('#elm1').xheditor({shortcuts:{'ctrl+enter':submitForm}});
});
}