ExtJs Event Delegation
1596 단어 ExtJsdelegation
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'
}
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
ExtJs:xtype의 의미내가 EXT 포럼에서 관찰한 바에 의하면 xtype를 사용할 때 의혹이 비교적 많을 것이다.심지어 어떤 사람들은 xtype를 아예 무시하거나 그것이 무엇인지 잘 모른다.그래서 나는 이 xtype의 개념을 논술하기로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.