问题
How can I call a handler from an button event? I want to click event a button and call that button handler?
Ext.getCmp('buttonID').click();
/// How to fire handler of that button?
回答1:
You may get this way:
var button = Ext.getCmp('buttonID');
button.fireEvent('click', button);
The second param must be button
if you want to keep hanlder logic equals to common button's clicking
回答2:
Ext itself does it this way:
var btn = Ext.getCmp('buttonID');
var e = null; // we don't have any event, so let's use nothing
Ext.callback(btn.handler, btn.scope, [btn, e], 0, btn);
If your handler depends on the event, it will not work...
来源:https://stackoverflow.com/questions/29834028/programmatically-call-handler-of-a-button-event