Extjs源码之---Ext.util.DelayedTask
/* 创建对象 var task = new Ext.util.DelayedTask(function(){ alert(Ext.getDom('myInputField').value.length); }); 调用执行 Ext.get('myInputField').on('keypress', function(){ task.{@link #delay}(500); }); */ Ext.util.DelayedTask = function(fn, scope, args){ var me = this, id, call = function(){ clearInterval(id);//这里感觉这里有点多余, me.cancel已经有做这个动作,是不是重复了,不知道作者处于何意 id = null; fn.apply(scope, args || []); }; //设置delay 参数信息 me.delay = function(delay, newFn, newScope, newArgs){ me.cancel();//先清除当前对象的定期器 fn = newFn || fn;//设置调用函数 scope = newScope || scope;//调用函数的作用域 args = newArgs || args;//调用函数的参数 id = setInterval(call, delay);//运行函数 }; //清楚定时器 me.cancel = function(){ if(id){ clearInterval(id); id = null; } }; }; //这个函数用在对输入校验的时候特别管用,特别是对于suggest这样的应用,可以减少服务端压力,
相关推荐
InJavaWeTrust 2020-05-15
Chydar 2012-09-20
natejeams 2020-01-15
zcpHappy 2014-01-11
pythonclass 2019-11-07
JF0 2019-11-03
ElementW 2015-02-15
干货集合 2014-05-14
kaiya0 2012-06-13
cscscssjsp 2012-03-05
drinow 2019-07-12
coderMozart 2019-06-30
t0ckh 2012-11-11
中等偏下 2017-02-22
nicepainkiller 2016-07-26
xiaoren 2016-02-10
云帆大数据 2016-01-11