做好县级经销商渠道管理以及市场的战略方向
2011-06-30 01:07
447 查看
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:
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:
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' } }
相关文章推荐
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- 市场前景广阔 渠道如何做好刀片服务器销售
- 从诺基亚看跨国企业如何在中国市场开展战略管理
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- 深耕市场从渠道生态入手 IBM推智慧新战略 推荐
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- 简析中国智能家居市场现状以及未来发展方向
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- Nokia提供的手机游戏以及内容的市场和渠道资料
- 移动管理平台:MDM市场诸侯混战,烽火发布MobileArk战略布局
- 对经销商而言 应当如何做好物流管理?
- 品设计体会(8005)战略管理和市场细分
- 方向α与管理理论——竞争战略、管理…
- Golang项目管理实践一--Golang包管理特点以及Glide工具的使用