博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个很好介绍js的例子
阅读量:4602 次
发布时间:2019-06-09

本文共 1767 字,大约阅读时间需要 5 分钟。

function UpdateInit(opt){

this.init(opt);
}

UpdateInit.prototype={

loadUrl:null,
loadParam:null,
beforeLoad:null,
afterLoad:null,
beforeInit:null,
afterInit:null,
customInit:null,
init:function(opt){
this.loadUrl=opt.loadUrl;
this.loadParam=opt.loadParam;
this.beforeLoad=opt.afterLoad;
this.afterLoad=opt.afterLoad;
this.beforeInit=opt.beforeInit
this.afterInit=opt.afterInit;
this.customInit=opt.customInit;
},
load:function(){
if(typeof(this.beforeLoad)=="function"){
this.beforeLoad(this);
}
var param={};
param.reqUrl=this.loadUrl;
param.reqData=this.loadParam;
if(typeof(this.customInit)=="function"){
ajaxRequest(param,this.customInit,this.loadError,null,this);
}
else{
ajaxRequest(param,this.initData,this.loadError,this,this);
}
},
initData:function(d){
if(!d){
return;
}
if(typeof(this.afterLoad)=="function"){
this.afterLoad();
}
if(typeof(this.beforeInit)=="function"){
this.beforeInit(d);
}
var itms=$(":input[type!='button']");
var $divInputer=null;
var tempVal=null;
for(var i=0,len=itms.length;i<len;i++){
tempVal=d[itms[i].name];
tempVal=tempVal!=null&&tempVal!="null"?tempVal:"";
if(typeof tempVal =="string"){
tempVal=tempVal.toString().replace(/(^\s*)|(\s*$)/g, "");
}
//保留几位小数
var dec=$(itms[i]).attr("decim");
if(tempVal===0||(dec!=null&&tempVal!=null&&tempVal!=""&&!isNaN(dec)&&!isNaN(tempVal)&&dec>0&&dec<20))
{
tempVal=tempVal.toFixed(dec);
}
$(itms[i]).val(tempVal);
$divInputer=$("#for_"+itms[i].name);
if($divInputer.length>0){
$divInputer.append(tempVal);
//$divInputer.append("").focus();
//$divInputer.html($divInputer.html());
}
}
if(typeof(this.afterInit)=="function"){
this.afterInit(d);
}
},
loadError:function(){
if(typeof(this.afterLoad)=="function"){
this.afterLoad();
}
}

};

转载于:https://www.cnblogs.com/mengziHEHE/p/3331063.html

你可能感兴趣的文章
hdu - 2266 How Many Equations Can You Find (简单dfs)
查看>>
UIView属性
查看>>
将博客搬至CSDN
查看>>
Java线程Dump分析工具--jstack【转载】
查看>>
day32(网络编程1)
查看>>
远程服务器git搭建
查看>>
牛人们的博客地址
查看>>
Zabbix是什么?
查看>>
源码:COCO微博
查看>>
面向对象预习随笔
查看>>
大数据概念炒作周期模型
查看>>
排序模型
查看>>
Dede推荐文章与热点文章不显示?
查看>>
从macOS Sierra 10.12.6 到win10
查看>>
ZeroMQ,史上最快的消息队列
查看>>
React 3
查看>>
Topshelf 使用
查看>>
Linux --Apache服务搭建
查看>>
调试SQLSERVER (二)使用Windbg调试SQLSERVER的环境设置 ------符号文件
查看>>
stanford CS DB 课程 数据库系统实现
查看>>