首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

让jquery-easyui的Form加载数据也和EXT一样有地图ping转定义功能

2012-09-02 
让jquery-easyui的Form加载数据也和EXT一样有mapping转定义功能!DOCTYPE html PUBLIC -//W3C//DTD HTML

让jquery-easyui的Form加载数据也和EXT一样有mapping转定义功能

<!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>jQuery EasyUI</title>    <style type="text/css">        label        {            width: 120px;            display: block;        }    </style>    <script type="text/javascript">        function loaddata1() {            $('#ff').form('load', 'home/loaduserinfo');        }        function loaddata2() {            $('#ff').form('load', {                users: { name: '我是谁', email: 'mymail@gmail.com', subject: 'subject2' },                infos: { message: '留言啦', language: 5 }            });        }        function cleardata() {            $('#ff').form('clear');        }        $(function() {            $('#ff').form({ url: 'home/adduserinfo', success: function(data) { },                fields: [{ name: 'name', mapping: 'users.name' }, { name: 'email', mapping: 'users.email' }, { name: 'subject', mapping: 'users.subject' },                        { name: 'message', mapping: 'infos.message' }, { name: 'language', mapping: 'infos.language'}]            });        });    </script></head><body>    <h1>        表单例子</h1>    <div>        <a href="#" onclick="loaddata1()">加载1</a> <a href="#" onclick="loaddata2()">加载2</a>        <a href="#" onclick="cleardata()">清除</a>    </div>    <div style="background: #fafafa; padding: 10px; width: 300px; height: 300px;">        <form id="ff" method="post">        <div>            <label for="name">                姓名:</label>            <input type="text" name="name" required="true" missingmessage="必填"></input>        </div>        <div>            <label for="email">                电子邮件:</label>            <input type="text" name="email" validtype="email"></input>        </div>        <div>            <label for="subject">                专业:</label>            <input type="text" name="subject"></input>        </div>        <div>            <label for="message">                信息:</label>            <textarea name="message" style="height: 60px;"></textarea>        </div>        <div>            <label for="language">                语言:</label>            <input name="language" url="combobox_data.json" valuefield="id"                textfield="text" panelheight="auto">        </div>        <div>            <input id="btns" type="submit" value="提交">        </div>        </form>    </div></body></html>

?jquery-easyui.min.js修改4435行如下

$("textarea[name=" + field.name + "]", form).val(val);
$("select[name=" + field.name + "]", form).val(val);
var cc = ["combo", "combobox", "combotree", "combogrid", "datebox", "datetimebox"];
for (var i = 0; i < cc.length; i++) {
_30b(cc[i], field.name, val);
}
}
/*for(var name in data){
var val=data[name];
$("input[name="+name+"]",form).val(val);
$("textarea[name="+name+"]",form).val(val);
$("select[name="+name+"]",form).val(val);
var cc=["combo","combobox","combotree","combogrid","datebox","datetimebox"];
for(var i=0;i<cc.length;i++){
_30b(cc[i],name,val);
}
}*/?完成了 2 楼 hjzhbb7758 2012-05-04   而且. 我觉得拓展一下,要好点. 改源码不太规范吧 .如果再更新版本. 又要重写

热点排行