0

I know something about DOM query but this won't help me solving this problem. I need to attach multiple events to multiple text fields in application launch Extjs 4. How do i do that?

Molecular Man
  • 22,277
  • 3
  • 72
  • 89
Bikash Shrestha
  • 51
  • 1
  • 1
  • 4
  • Did you read documentation before posting question here ? – Snake Eyes Jun 21 '13 at 11:08
  • read http://stackoverflow.com/questions/7260134/extjs-4-event-handling-tutorial and http://stackoverflow.com/questions/4225389/how-do-i-attach-an-event-handler-to-a-panel-in-extjs – Snake Eyes Jun 21 '13 at 11:20
  • i have read it ,can you help me Snake Eyes.i need to attach events to all current n future generated text field using class name(components not dom elements ) – Bikash Shrestha Jun 21 '13 at 11:27

1 Answers1

0

If you want to assign event handlers to dom elements before the elements are created then you can use this answer https://stackoverflow.com/a/8081472/842075.

If you want to assign event handlers to components before the components are created then all you need is Ext.app.EventBus.controll method (it is used internally by mvc controllers):

var listeners = {
    'textfield[cls="mycls"]': {
        change: function() { alert('textfield with cls="mycls" changed'); }
    }
};
Ext.app.EventBus.control(listeners, scopeObject);

Note that Ext.app.EventBus is not present in sencha docs. The examples of usage of control method may be found in documentation for Ext.app.Controller.control method.

Here's demo.

If you are using extjs mvc than just use Ext.app.Controller.control method.

Community
  • 1
  • 1
Molecular Man
  • 22,277
  • 3
  • 72
  • 89