Event handlers are a common cause of memory leaks and can cause performance degradation when not managed carefully. The more event handlers we create the more likely we are to introduce such problems, so we should try to avoid creating huge numbers of handlers when we don't have to.
Event delegation is a technique where a single event handler is created on a parent element, which leverages the fact that the browser will bubble any events raised on one of its children to this parent element. If the target of the original event matches the delegate's selector then it will execute the event handler, otherwise nothing will happen.
This means that instead of attaching an event handler to each individual child element, we only have to create a single handler on the parent element and then, within the handler, query which child element was actually clicked, and react appropriately.
Example:
<div id='mydiv'>
<li>1</li>
<li>2</li>
<li>3</li>
</div>
Attach an event handler to the list's click event and specify we want to delegate
this event to the list items (that is LI tags), by passing a configuration object to
the on method's fourth argument, containing the delegate property:
Ext.get('mydiv').on('click', function(e, target, options){
alert(target.innerHtml);
}, this, {
delegate: 'li'
}
}
分享到:
相关推荐
EXTJS应用EXTJS应用EXTJS应用EXTJS应用EXTJS应用EXTJS应用
extjs资料extjs资料extjs资料extjs资料extjs资料
Extjs例子Extjs例子Extjs例子Extjs例子Extjs例子
extjs4.0 技术中文视频讲解,内容非常的全... 第七讲:extjs4.0的事件机制Event 第八讲:extjs4.0的Ajax 第九讲:extjs4.0的core包和Ext类 第十讲:extjs4.0的util包 论坛地址是: http://www.uspcat.com/?fromuid=413
[07]EXTJS4.0的事件机制Event.001.zip (70.00M)[07]EXTJS4.0的事件机制Event.003.zip [07]EXTJS4.0的事件机制Event.002.zip 第八讲:extjs4.0的Ajax [08]EXTJS4.0的Ajax.003.zip (53.77M)[08]EXTJS4.0的Ajax....
ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门 ExtJS快速入门ExtJS快速入门 ExtJS快速入门 ExtJS...
xtJs已经升级到了5.0了,目前可能多数应用还在使用ExtJs 3.系列。 从开发大型的web后台或者企业管理系统来看,ExtJs3的缺陷还是比较明显的,从ExtJs4 开始引入了MVC架构,从而能够从容的组织系统的JS文件了。 从...
[07]EXTJS4.0的事件机制Event.001.zip (70.00M)[07]EXTJS4.0的事件机制Event.003.zip [07]EXTJS4.0的事件机制Event.002.zip 第八讲:extjs4.0的Ajax [08]EXTJS4.0的Ajax.003.zip (53.77M)[08]EXTJS4.0的Ajax....
EXTJS实例 EXTJS树,可以编辑的EXTJS,EXTJS3.0
extjs电子书,extjs电子书,extjs电子书,extjs电子书
extJs3升级extjs4方案, extJs3升级extjs4需要修改大量代码
extjsapi,extjs文档,api手岫
包含各种类型的extjs小图标,Extjs4小图标
一个extjs的OA项目 extjs-OA extjs-oaextjs-OA extjs-oa
JBPM4 SSH EXTJS JBPM SSH EXTJS JBPM4 SSH EXTJS JBPM SSH EXTJS JBPM4 SSH EXTJS JBPM SSH EXTJS JBPM4 SSH EXTJS JBPM SSH EXTJS 希望对大家有帮助。
适合ExtJs开发人员extjs技术上手以及深入
一 Extjs 基础 EXTJS4自学手册——EXT文件目录,本地加载文档,命名规范 EXTJS4自学手册——EXT基本方法、属性(onReady、define、create) EXTJS4自学手册——EXT基本方法、属性(apply、applyIf、constructor) ...
开始ExtJS之旅的第一步是要获得开发包,可以从官方网站www.ExtJS.com下载,以保证获 得最新版本。其下载地址是http://www.ExtJS.com/download,下载成功后的开发包是ExtJS- 2.0.2.zip,有6.08MB大。不过不用担心,这...
项目进行前端框架升级——extJS 4升级至extJS6.6所遇的一些问题及相对应的解决方案建议
里面包含Extjs 2.2和Extjs 3.2.1版本两个文件