input输入框实时监控 并实现延迟发起请求
2016-06-01 12:44
381 查看
input输入框实时监控 并实现延迟发起请求
实时监控input代码autoWatch:function(){
var that=this;
var $ele=$(this.element);
$ele.on('input propertychange',function(){
//console.log($(this));
var oldValue=$(this).data('oldValue');
var newValue=$(this).val();
if(oldValue==newValue){
//console.log('oldValue==newValue');
that.show();
return false;
}else{
//that.requestData(newValue);
that.delayRequest(newValue,0);
}
})
}
延迟处理代码
var timer=false //定义全局timer
delayRequest:function(newValue,i){//延时请求处理
var that=this;
var j=10;
if(timer){
clearInterval(timer);
}
timer=setInterval(function(){
++i;
if(i==j){
console.log(i,j);
that.requestData(newValue);
clearInterval(timer);
}
},100);
}i初始值为0 一秒后执行请求 调用that.requestData();
实时监控input代码autoWatch:function(){
var that=this;
var $ele=$(this.element);
$ele.on('input propertychange',function(){
//console.log($(this));
var oldValue=$(this).data('oldValue');
var newValue=$(this).val();
if(oldValue==newValue){
//console.log('oldValue==newValue');
that.show();
return false;
}else{
//that.requestData(newValue);
that.delayRequest(newValue,0);
}
})
}
延迟处理代码
var timer=false //定义全局timer
delayRequest:function(newValue,i){//延时请求处理
var that=this;
var j=10;
if(timer){
clearInterval(timer);
}
timer=setInterval(function(){
++i;
if(i==j){
console.log(i,j);
that.requestData(newValue);
clearInterval(timer);
}
},100);
}i初始值为0 一秒后执行请求 调用that.requestData();
相关文章推荐
- 基于linux下的变量声明declare的用法
- linux常用命令
- log4j.properties 的使用详解
- 事实证明,OpenCV中对RGB图像数据的存储顺序是BGR,而且Scalar()的顺序也是B,G,R
- Linux - PCB之task_struct结构体
- 每秒处理10万订单乐视集团支付架构
- linux 安装MySQL 相关问题
- CentOS查看系统信息
- calcHist()计算图像直方图opencv
- Windows中如何在Visual Studio 2015环境里编译OpenCV 3.1并加入opencv_contrib-master
- windows与centos linux系统相互快捷上传下载命令
- 云服务器上Wamp搭建网站
- tomcat优化
- centos误删除文件如何恢复,恢复方法
- opencv中Mat与IplImage,CVMat类型之间转换
- centos could not retrieve mirrorlist
- 在生产环境使用Docker部署应用
- 在虚拟机中的linux的ftp的基本配置 (2011-03-08 10:53:03)
- StopWatch计算计时工具类
- Nginx服务器防止被压力测试