页面异步保存列表列
来源:互联网 发布:怎样才能赚到钱 知乎 编辑:程序博客网 时间:2024/04/29 08:59
需求
1. 客户有一个需要,需要在列表页面中的某一列直接进行修改操作。如下:需要修改"实地落地"这一列。
实现
1 基本想法就是使用jquery的插件,所以经过一些筛选找到了joytech这个组件,并且进行了一些二次开发。
1 引用js
<script language="javascript" type="text/javascript" src="${cssPath}/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" language="javascript" src="${cssPath}/js/jquery.joytech.core.js"></script>
<script type="text/javascript" language="javascript" src="${cssPath}/js/jquery.joytech.editable.js"></script>
2 列表定义
定义一个class为 editable,用于对列进行选择(方便使用jquery选择器)
<div class="w100 editable" onClick="{currId='${ts.id}'}" > ${ts.realityLandingTime} </div>
3 代码实现
var currId = "";function submitDo(oldValue,changeValue){//alert(oldValue);//alert(changeValue);// alert("submitDo1..." + currId + " "+changeValue);if(oldValue==changeValue){return;}$.ajax({ url:'/flight34/train/updateRealityLandingTime.do', //url:'${ctx}/index.jsp', async:false, cache:false, type:'post', dataType:'html', data:{ tsid:currId, realityLandingTime:changeValue, contentType: "application/x-www-form-urlencoded;charset=utf-8" }, success:function(html){ // alert(html) $("#warn").html("操作成功"); fail(); } }); }$(document).ready(function () {if($("#phase").val()==9){$(".editable").editableText(submitDo);}});
依赖js文件
备注:这里我对joytech做过二次开发,主要是添加了异步提交方法
jquery.joytech.core.js
(function ($, undefined) { $.joytech = $.joytech || {};})(jQuery);
jquery.joytech.editable.js
/*!* jQuery joytech editable 1.0.0*** Depends:*jquery.joytech.core.js*/(function ($) { $.joytech._editable = { _editor: null, _richeditor: null, _currenteditor: null, _holder: null,_submit: null, _blur: function (event) { var pthis = $.joytech._editable; if (pthis._holder) { var e = $(pthis._holder); switch (e.attr("joytech_editable_type")) { case 'text': e.text(pthis._currenteditor.value); break; case 'html': e.html(pthis._currenteditor.value); break; case 'value': e.val(pthis._currenteditor.value); break; } pthis._holder = null; $(pthis._currenteditor).hide(); } // alert("...");$.joytech._editable._submit(pthis._currenteditor.oldValue,pthis._currenteditor.value); return false; }, _click: function (event) { var pthis = $.joytech._editable; if (pthis._editor == null) { $(document.body).append("<input type='text' style='position:absolute;' id='joytech__editable__editor'/>"); pthis._editor = $('#joytech__editable__editor')[0]; $(pthis._editor).blur($.joytech._editable._blur).hide(); } if (pthis._richeditor == null) { $(document.body).append("<textarea style='position:absolute;' id='joytech__editable__richeditor'/>"); pthis._richeditor = $('#joytech__editable__richeditor')[0]; $(pthis._richeditor).blur($.joytech._editable._blur).hide(); } pthis._holder = event.target; var e = $(event.target); var bricheditor = (e.attr("joytech_editable_type")) == 'html' && (e.attr("joytech_editable_usingricheditor")=='true'); if (bricheditor) pthis._currenteditor = pthis._richeditor; else pthis._currenteditor = pthis._editor; var i = $(pthis._currenteditor); var value = ''; switch (e.attr("joytech_editable_type")) { case 'text': value = e.text(); break; case 'html': value = e.html(); break; case 'value': value = e.val(); break; } if (bricheditor) i.val(value); else i.val(value); pthis._currenteditor.oldValue = value; var o = e.offset(); i.css({ left: o.left, top: o.top, width: e.width(), height: e.height() }).show().focus(); return false; } }; $.fn.editableHTML = function (usingricheditor) { this.attr("joytech_editable_type", "html"); this.attr("joytech_editable_usingricheditor", usingricheditor); this.dblclick($.joytech._editable._click); return $; }; $.fn.editableText = function (submitFunc) {$.joytech._editable._submit = submitFunc; this.attr("joytech_editable_type", "text"); this.dblclick($.joytech._editable._click); return $; }; $.fn.editableValue = function () { this.attr("joytech_editable_type", "value"); this.click($.joytech._editable._click); return $; };})(jQuery);
0 0
- 页面异步保存列表列
- XML保存HTML页面的下拉列表内容
- Sharepoint2013 列表的NewForm 页面添加一个 保存新建 按钮
- 页面获取列表数据和数据库对比并保存
- emap开发平台中,保存提示保存成功后,回到高级搜索列表页面,表格缩成一团
- 异步页面
- 异步页面
- 页面列表
- Android--异步保存图片
- ajax异步数据保存
- SharePoint 自定义列表页面定制续—[保存模板后不能正常使用]
- C# 利用函数反射、XML序列化/反序列化保存函数执行与输入参数列表
- cookie保存散列表
- 一种异步保存的思路
- 异步保存程序运行日志
- jquery ajax异步保存数据
- 新建DataColumn列保存二进制文件
- 各队列同步异步操作
- (解决)Ubuntu14.04右上角出现红色三角号里面有红色感叹号
- Ping得通,但是访问不了局域网内的电脑的解决办法
- Java进阶之欧拉工程 第十五篇【网格路径问题】
- Android 农历日历算法
- UVA - 10780 Again Prime? No Time. (质因子分解)
- 页面异步保存列表列
- JNA结构体数组
- hdu1429胜利大逃亡(续)(状态压缩+bfs)
- PAT_B_循环-23. 找完数(20)
- ios7 上修改状态栏颜色
- IOS 崩溃日志调试
- 黑马程序员-----异常
- Unity3d中制作Loading场景进度条所遇到的问题
- 如何访问google?