SCRIPT5022: form element not null
本帖最后由 LotusTree 于 2013-12-20 11:24 编辑IE10的时候还好,能在10兼容模式和IE7下正常工作,昨天升级到11了就不行了。从6到11只有一个版本能搞定。。这也太挑剔了。所以还是决定改下代码。不会,来着求教!!!
这是报错的部分。
throw new Error("form element not null");mini.Form(this)};O1oO(mini.Form,o0OOoo,{el:null,getFields:function(){if(!this.el)return[];var $=mini.findControls(function($){if(!$.el||$.formField!=true)return false;if(l0O1O(this.el,$.el))return true;return false},this);return $}
这是页面代码<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>部门管理</title>
<script src="../scripts/boot.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" action="" method="post">
<!--操作部分-->
<div style="width: 800px;">
<div class="mini-toolbar" style="border-bottom: 0; padding: 0px;">
<table style="width: 100%;">
<tr>
<td style="width: 100%;">
<a class="mini-button" iconcls="icon-add" onclick="add()">增加</a> <a class="mini-button"
iconcls="icon-add" onclick="edit()">编辑</a> <a class="mini-button" iconcls="icon-remove"
onclick="remove()">删除</a>
</td>
</tr>
</table>
</div>
</div>
<!--数据表-->
<div id="datagrid1" class="mini-datagrid" style="width:800px; height: 280px;" allowresize="true"
url="../ashx/Handler.ashx?method=SearchDepartment" idfield="id" multiselect="true">
<div property="columns">
<div type="indexcolumn" width="5"></div>
<div type="checkcolumn" width="5">
</div>
<div field="DepId" width="15" headeralign="center" allowsort="true">
部门编号</div>
<div field="DepName" width="15" headeralign="center" allowsort="true">
名称</div>
<div field="Remark"width="70" headeralign="center" allowsort="true">
备注</div>
</div>
</div>
</form>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid1");
grid.load();
function add() {
mini.open({
url: bootPATH + "../Department/DepartmentWindow.htm",
title: "新增部门", width: 250, height: 150,
onload: function () {
var iframe = this.getIFrameEl();
var data = { action: "new" };
iframe.contentWindow.SetData(data);
},
ondestroy: function (action) {
grid.reload();
}
});
}
function edit() {
var row = grid.getSelected();
if (row) {
mini.open({
url: bootPATH + "../Department/DepartmentWindow.htm",
title: "编辑部门", width: 250, height: 150,
onload: function () {
var iframe = this.getIFrameEl();
var data = { action: "edit", id: row.DepId };
iframe.contentWindow.SetData(data);
},
ondestroy: function (action) {
grid.reload();
}
});
} else {
alert("请选中一条记录");
}
}
function remove() {
var rows = grid.getSelecteds();
if (rows.length > 0) {
if (confirm("确定删除选中记录?")) {
var ids = [];
for (var i = 0, l = rows.length; i < l; i++) {
var r = rows;
ids.push(r.DepId);
}
var id = ids.join(',');
grid.loading("操作中,请稍后......");
$.ajax({
url: "../ashx/Handler.ashx?method=RemoveDepartment&id=" + id,
success: function (text) {
alert(text);
grid.reload();
},
error: function () {
}
});
}
} else {
alert("请选中一条记录");
}
}
function search() {
var key = mini.get("key").getValue();
grid.load({ key: key });
}
function onKeyEnter(e) {
search();
}
function onMarriedRenderer(e) {
if (e.value == 1) return "是";
else return "否";
}
</script>
</body>
</html>
IE11我们还在测试调试中
IE的话只支持IE6-10的标准模式 felt 发表于 2013-12-20 10:31 static/image/common/back.gif
IE11我们还在测试调试中
IE的话只支持IE6-10的标准模式
不怀疑控件的问题,我有两个页面有添加编辑的选项,另一个如你所说,6-10都没问题。就是部门这个页面有问题。所以请教一下,上面的代码我是不是少写了什么。这个也面的代码基本上是康吹加威过来的。只是开始的时候我没写表单标签。后来加上去了还是不行。还有一个不同是另一个正常的页面跳转的添加和编辑是分开的页面,而这个是跳转到同一个页面。
小白求教! LotusTree 发表于 2013-12-20 10:39 static/image/common/back.gif
不怀疑控件的问题,我有两个页面有添加编辑的选项,另一个如你所说,6-10都没问题。就是部门这个页面有问 ...
你看下子页面的SetDate()方法有没有问题 本帖最后由 LotusTree 于 2013-12-20 11:25 编辑
felt 发表于 2013-12-20 10:50 static/image/common/back.gif
你看下子页面的SetDate()方法有没有问题
刚刚说,IE7的浏览器模式可以搞定,那么代码上我就真看不出什么东西来了。面对浏览器的什么所谓解析方式我实在是太纯洁了!!!所以还是请高人您帮我看看吧!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
html, body
{
font-size: 12px;
padding: 0;
margin: 0;
border: 0;
height: 100%;
overflow: hidden;
}
</style>
<title>部门面板</title>
</head>
<body>
<form name="form1" method="post">
<input name="DepId" class="mini-hidden" />
<table style="table-layout: fixed;">
<tr>
<td style="width: 70px;">
部门名称:
</td>
<td style="width: 150px;">
<input name="DepName" class="mini-textbox" onvalidation="onChineseValidation" required="true" emptytext="请输入部门名称" vtype="maxLength:10" />
</td>
</tr>
<tr>
<td style="width: 70px;">
备注:
</td>
<td style="width: 150px;">
<input name="Remark" class="mini-textbox" required="false" vtype="maxLength:50" />
</td>
</tr>
</table>
<div style="text-align:center;padding:10px;">
<a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
<a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
</div>
</form>
</body>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");
function SaveData() {
var o = form.getData();
form.validate();
if (form.isValid() == false) return;
var json = mini.encode();
$.ajax({
url: "../ashx/Handler.ashx?method=SaveDepartment",
type: 'post',
data: { data: json },
cache: false,
success: function (text) {
alert(text);
CloseWindow("save");
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
CloseWindow();
}
});
}
function SetData(data) {
if (data.action == "edit") {
//跨页面传递的数据对象,克隆后才可以安全使用
data = mini.clone(data);
$.ajax({
url: "../ashx/Handler.ashx?method=GetDepartment&id=" + data.id,
cache: false,
success: function (text) {
var o = mini.decode(text);
form.setData(o);
form.setChanged(false);
}
});
}
}
function GetData() {
var o = form.getData();
return o;
}
function CloseWindow(action) {
if (action == "close" && form.isChanged()) {
if (confirm("数据被修改了,是否先保存?")) {
return false;
}
}
if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
else window.close();
}
function onOk(e) {
SaveData();
}
function onCancel(e) {
CloseWindow("cancel");
}
//验证
function onChineseValidation(e) {
if (e.isValid) {
if (isChinese(e.value) == false) {
e.errorText = "必须输入中文";
e.isValid = false;
}
}
}
/* 是否汉字 */
function isChinese(v) {
var re = new RegExp("^[\u4e00-\u9fa5]+$");
if (re.test(v)) return true;
return false;
}
</script>
</html>
LotusTree 发表于 2013-12-20 11:01 static/image/common/back.gif
刚刚说,IE7的浏览器模式可以搞定,那么代码上我就真看不出什么东西来了。面对浏览器的什么所谓解析方式 ...
你运行哪个会有问题?
另外上传页面可以用高级模式打包的 本帖最后由 LotusTree 于 2013-12-20 11:21 编辑
felt 发表于 2013-12-20 11:09 static/image/common/back.gif
你运行哪个会有问题?
另外上传页面可以用高级模式打包的
从这个页面<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>部门管理</title>
<script src="../scripts/boot.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" action="" method="post">
<!--操作部分-->
<div style="width: 800px;">
<div class="mini-toolbar" style="border-bottom: 0; padding: 0px;">
<table style="width: 100%;">
<tr>
<td style="width: 100%;">
<a class="mini-button" iconcls="icon-add" onclick="add()">增加</a> <a class="mini-button"
iconcls="icon-add" onclick="edit()">编辑</a> <a class="mini-button" iconcls="icon-remove"
onclick="remove()">删除</a>
</td>
</tr>
</table>
</div>
</div>
<!--数据表-->
<div id="datagrid1" class="mini-datagrid" style="width:800px; height: 280px;" allowresize="true"
url="../ashx/Handler.ashx?method=SearchDepartment" idfield="id" multiselect="true">
<div property="columns">
<div type="indexcolumn" width="5"></div>
<div type="checkcolumn" width="5">
</div>
<div field="DepId" width="15" headeralign="center" allowsort="true">
部门编号</div>
<div field="DepName" width="15" headeralign="center" allowsort="true">
名称</div>
<div field="Remark"width="70" headeralign="center" allowsort="true">
备注</div>
</div>
</div>
</form>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid1");
grid.load();
function add() {
mini.open({
url: bootPATH + "../Department/DepartmentWindow.htm",
title: "新增部门", width: 250, height: 150,
onload: function () {
var iframe = this.getIFrameEl();
var data = { action: "new" };
iframe.contentWindow.SetData(data);
},
ondestroy: function (action) {
grid.reload();
}
});
}
function edit() {
var row = grid.getSelected();
if (row) {
mini.open({
url: bootPATH + "../Department/DepartmentWindow.htm",
title: "编辑部门", width: 250, height: 150,
onload: function () {
var iframe = this.getIFrameEl();
var data = { action: "edit", id: row.DepId };
iframe.contentWindow.SetData(data);
},
ondestroy: function (action) {
grid.reload();
}
});
} else {
alert("请选中一条记录");
}
}
function remove() {
var rows = grid.getSelecteds();
if (rows.length > 0) {
if (confirm("确定删除选中记录?")) {
var ids = [];
for (var i = 0, l = rows.length; i < l; i++) {
var r = rows;
ids.push(r.DepId);
}
var id = ids.join(',');
grid.loading("操作中,请稍后......");
$.ajax({
url: "../ashx/Handler.ashx?method=RemoveDepartment&id=" + id,
success: function (text) {
alert(text);
grid.reload();
},
error: function () {
}
});
}
} else {
alert("请选中一条记录");
}
}
function search() {
var key = mini.get("key").getValue();
grid.load({ key: key });
}
function onKeyEnter(e) {
search();
}
function onMarriedRenderer(e) {
if (e.value == 1) return "是";
else return "否";
}
</script>
</body>
</html>
到这个页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
html, body
{
font-size: 12px;
padding: 0;
margin: 0;
border: 0;
height: 100%;
overflow: hidden;
}
</style>
<title>部门面板</title>
</head>
<body>
<form name="form1" method="post">
<input name="DepId" class="mini-hidden" />
<table style="table-layout: fixed;">
<tr>
<td style="width: 70px;">
部门名称:
</td>
<td style="width: 150px;">
<input name="DepName" class="mini-textbox" onvalidation="onChineseValidation" required="true" emptytext="请输入部门名称" vtype="maxLength:10" />
</td>
</tr>
<tr>
<td style="width: 70px;">
备注:
</td>
<td style="width: 150px;">
<input name="Remark" class="mini-textbox" required="false" vtype="maxLength:50" />
</td>
</tr>
</table>
<div style="text-align:center;padding:10px;">
<a class="mini-button" onclick="onOk" style="width:60px;margin-right:20px;">确定</a>
<a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
</div>
</form>
</body>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form1");
function SaveData() {
var o = form.getData();
form.validate();
if (form.isValid() == false) return;
var json = mini.encode();
$.ajax({
url: "../ashx/Handler.ashx?method=SaveDepartment",
type: 'post',
data: { data: json },
cache: false,
success: function (text) {
alert(text);
CloseWindow("save");
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
CloseWindow();
}
});
}
function SetData(data) {
if (data.action == "edit") {
//跨页面传递的数据对象,克隆后才可以安全使用
data = mini.clone(data);
$.ajax({
url: "../ashx/Handler.ashx?method=GetDepartment&id=" + data.id,
cache: false,
success: function (text) {
var o = mini.decode(text);
form.setData(o);
form.setChanged(false);
}
});
}
}
function GetData() {
var o = form.getData();
return o;
}
function CloseWindow(action) {
if (action == "close" && form.isChanged()) {
if (confirm("数据被修改了,是否先保存?")) {
return false;
}
}
if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
else window.close();
}
function onOk(e) {
SaveData();
}
function onCancel(e) {
CloseWindow("cancel");
}
//验证
function onChineseValidation(e) {
if (e.isValid) {
if (isChinese(e.value) == false) {
e.errorText = "必须输入中文";
e.isValid = false;
}
}
}
/* 是否汉字 */
function isChinese(v) {
var re = new RegExp("^[\u4e00-\u9fa5]+$");
if (re.test(v)) return true;
return false;
}
</script>
</html>
删除可以,添加和修改都不行 LotusTree 发表于 2013-12-20 11:19 static/image/common/back.gif
从这个页面到这个页面删除可以,添加和修改都不行
var form = new mini.Form("form1"); // 你的代码
莫非是这个var form = new mini.Form("#form1");?
压缩打包页面上传,不要直接贴:L felt 发表于 2013-12-20 13:26 static/image/common/back.gif
var form = new mini.Form("form1"); // 你的代码
莫非是这个var form = new mini.Form("#form1");?
压 ...
算了,我再研究研究吧!我这贴代码不也是为了方便其他看客么,要是人家和我一个问题都省得下载了。。。。。 LotusTree 发表于 2013-12-20 14:40 static/image/common/back.gif
算了,我再研究研究吧!我这贴代码不也是为了方便其他看客么,要是人家和我一个问题都省得下载了。。。。 ...
楼主你好,我最近也遇到了 Form Element is not null 的问题了,你还记得你是什么原因导致的吗?
页:
[1]
2