0

我对 DOM 查询有所了解,但这无助于我解决这个问题。我需要在应用程序启动 Extjs 4 中将多个事件附加到多个文本字段。我该怎么做?

4

1 回答 1

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.

于 2013-06-21T13:42:42.530 回答