- 注册时间
- 2017-2-21
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 103
- 精华
- 0
- 帖子
- 24
|
本帖最后由 hw_2x_vc 于 2017-3-11 12:01 编辑
var json = mini.encode([o]); 这个方法 是根据 元素的name 和value 来生成数据的吗?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>枚举类别面板</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link href="/miniui/demo.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/miniui/scripts/boot.js"></script>
<script type="text/javascript" src="/miniui/core.js"></script>
<script type="text/javascript" src="/miniui/scripts/tongji.js" ></script>
<script type="text/javascript" src="/Content/style/lib/jquery-1.8.0.min.js"></script>
<style type="text/css">
html, body
{
font-size:12px;
padding:0;
margin:0;
border:0;
height:100%;
overflow:hidden;
}
</style>
</head>
<body>
<form id="form1" method="post">
<input id="pk" name="pk" class="mini-hidden" />
<div style="padding-left:11px;padding-bottom:5px;">
<table style="table-layout:fixed;">
<tr>
<td style="width:70px;">枚举类别:</td>
<td style="width:150px;">
<input id="cps_enumtype" name="enumtype" class="mini-textbox" required="true" emptyText="请输入类别"/>
</td>
</tr>
</table>
</div>
<div style="text-align:center;padding:10px;">
<a class="mini-button" style="width:60px;margin-right:20px;">确定</a>
<a class="mini-button" style="width:60px;">取消</a>
</div>
</form>
<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([o]);
$.ajax({
url: "/sysEnum/SaveEnum",
type: 'post',
data: { data: json },
cache: false,
success: function (text) {
CloseWindow("save");
},
error: function (jqXHR, textStatus, errorThrown) {
alert(jqXHR.responseText);
CloseWindow();
}
});
}
////////////////////
//标准方法接口定义
function SetData(data) {
if (data.action == "edit") {
//跨页面传递的数据对象,克隆后才可以安全使用
data = mini.clone(data);
//$("#cps_enumtype$text").val(data.enumtype);
$("#cps_pk").val(data.pk);
var oname = document.getElementById("cps_enumtype$text");
//id 自动增加了 $text 能说一说规则吗? 什么时候加 会加那些
oname.value = data.enumtype;
var oname = document.getElementById("pk");
oname.value = data.pk;
}
}
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");
}
</script>
</body>
</html>
运行后的前台 情况
<form id="form1" method="post">
<input type="hidden" class="mini-hidden" id="pk" name="pk" value="2">
<input type="hidden" class="mini-hidden" id="_state" name="_state" value="edit">
<div style="padding-left:11px;padding-bottom:5px;">
<table style="table-layout:fixed;">
<tbody><tr>
<td style="width:70px;">枚举类别:</td>
<td style="width:150px;">
<span class="mini-textbox mini-required" id="cps_enumtype" style="border-width: 0px;">
<span class="mini-textbox-border">
<input type="text" class="mini-textbox-input" autocomplete="off" placeholder="请输入类别" id="cps_enumtype$text" name="enumtype">
</span><input type="hidden">
</span>
</td>
</tr>
</tbody></table>
</div>
<div style="text-align:center;padding:10px;">
<a class="mini-button" href="javascript:void(0)" style="width: 60px; margin-right: 20px;"><span class="mini-button-text ">确定</span></a>
<a class="mini-button" href="javascript:void(0)" style="width: 60px;"><span class="mini-button-text ">取消</span></a>
</div>
</form>
后台的 json 自动pk 和_state 的值丢失了
[{"pk":"","_state":"","enumtype":"收费项目7898"}]
|
|