Wednesday, 10 September 2014

Extjs 4 : Delegating Events

Though ExtJS supports excellent event handling mechanism, sometimes we may want to handle custom events on some HTML components. For example if you want to handle hyperlink click whereas hyperlink is embedded in html code(using html tag or xtemplate), then you may need to delegate events to the component that you have created using 'delegate'. You can use simple hack to handle this.

  • Create HTML text using html tag or xtemplate. 
  • Assign classname/id to the component to which you want to attach an event. 
  • Attache event to the Ext body and delegate to the specific class/id show in below.
  • Make sure that class name or id is unique. 

Here is the fiddle to fiddle around with it.
Sample snippet

No comments:

Post a Comment