一个很好介绍js的例子
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();
}
}
};
一个很好介绍js的例子的更多相关文章
- 一个很好的JS,ASP二级下拉框联动。
在我们制作网站会员注册信息时,一般会涉及到填写自己所在省/市,如果用input或textarea做成填写形式不太理想.所以大部分网站都会选择联动下来列表形式,做起来也不算很复杂,同时看上去也很轻松. ...
- 推荐一个很棒的JS绘图库Flot
Flot是Ole Laursen开发的基于JQuery的纯JavaScript实现的绘图库,Flot使用起来非常简单,绘图效果相当绚丽,而且还支持一些图片的操作功能,例如图片的缩放.可以看一下Flot ...
- JS、JAVA刷题和C刷题的一个很重要的区别
就是最近在做树方面的题时,发现JS和JAVA刷题和C刷题的一个很重要的区别就是传入null的区别 当遍历的时候,C传参数时可以传进去null的指针,因为递归进去,出来时,指针还是指着那个地方 但是JS ...
- MVC已经是现代Web开发中的一个很重要的部分,下面介绍一下Spring MVC的一些使用心得。
MVC已经是现代Web开发中的一个很重要的部分,下面介绍一下Spring MVC的一些使用心得. 之前的项目比较简单,多是用JSP .Servlet + JDBC 直接搞定,在项目中尝试用 Strut ...
- node.js 如何处理一个很大的文件
node.js 如何处理一个很大的文件 思路 arraybuffer 数据分段 时间分片 多线程 web workers sevice workers node.js 如何处理一个很大的文件 http ...
- WCF技术剖析之三十:一个很有用的WCF调用编程技巧[下篇]
原文:WCF技术剖析之三十:一个很有用的WCF调用编程技巧[下篇] 在<上篇>中,我通过使用Delegate的方式解决了服务调用过程中的异常处理以及对服务代理的关闭.对于<WCF技术 ...
- 关于引入多个jquery冲突的问题(附一个很好用的validate前端验证框架及使用方法)
废话不多说,进入正题: 如果一个jsp中想要使用两个不同版本的jquery怎么办呢?客官往下看: <script src="${ctxStatic}/jquery/jquery-1.8 ...
- 一个完整的Node.js RESTful API
前言 这篇文章算是对Building APIs with Node.js这本书的一个总结.用Node.js写接口对我来说是很有用的,比如在项目初始阶段,可以快速的模拟网络请求.正因为它用js写的,跟i ...
- jetty 介绍以及小例子
Jetty 是一个开源的servlet容器,它为基于Java的web容器,例如JSP和servlet提供运行环境.Jetty是使用Java语言编写的,它的API以一组JAR包的形式发布.开发人员可以将 ...
随机推荐
- 测序深度和覆盖度(Sequencing depth and coverage)
总是跑数据,却对数据一无所知,这说不过去吧. 看几篇文章吧 Sequencing depth and coverage: key considerations in genomic analyses( ...
- struts2 I18N 国际化
1. 准备properties文件 globalMessages_en_US.properties globalMessages_zh_CN.properties 2. 配置struts.xml &l ...
- 例题:打印正三角形。两层for循环,难点明白行与列的关系
while (true) { string s = "★";//s代表五角星 string t = ...
- mysql spider之拆库无忧
数据库的三板斧 先上MySQL,之后再上读写分离,然后呢? 后面典型的做法是垂直拆库和水平分表. 一旦数据库拆了之后,代价就来了. 1.事务不能跨库了(少,但是很重要,可以适当改写) 2.相关的关联查 ...
- ASP.NET页面与IIS底层交互和工作原理详解
转载自:http://www.cnblogs.com/lidabo/archive/2012/03/13/2393200.html 第一回: 引言 我查阅过不少Asp.Net的书籍,发现大多数作者都是 ...
- 一些用于数据整理的excel函数
我们经常要从外部数据源(如数据库.文本文件或网页等)将数据导入excel中,但是此类数据往往比较混乱,无法满足我们的要求,因此在进行数据分析之前,需要将这些数据进行整理清洗,excel由于将数据的管理 ...
- mint上部署lamp环境
不得不说现在在linux mint上部署lamp很方便,比windows服务器上的asp.net的部署升级都简单. 1 安装MySql sudo apt-get install mysql-serve ...
- 5. Longest Palindromic Substring -- 最长回文字串
Given a string S, find the longest palindromic substring in S. You may assume that the maximum lengt ...
- java.lang.IllegalArgumentException: addChild: Child name '/SSHE' is not unique
错误信息: Caused by: java.lang.IllegalArgumentException: addChild: Child name '/SSHE' is not unique ...
- PLSQL DEVELOPER 连接远程数据库 OCI客户端安装方法
安装使用过PLSQL Dev都知道,要连接数据库,必须配置TNS(Transparence Network Substrate),而直接安装PLSQL Dev 之后,本机是没有Oracle HOME的 ...