The Ext.mixin.Observable
class also provides a way to fire events, whether these are framework events or custom events. The fireEvent
method will fire any event we require and pass parameters for consumption by the handler function. The following example shows us how to fire a custom confirmed
event, passing the choice
parameter on the button, and binding it to an onConfirmed
handler:
Ext.define('BizDash.view.main.MainController', { extend: 'Ext.app.ViewController', onConfirm: function (choice) { if (choice === 'yes') { var button = this.getView().getButton(); button.fireEvent('confirmed', choice) } }, onConfirmed: function(choice){ console.log('The CONFIRMED event was fired'); }, init: function () { button.on({ mouseover: 'onMouseOver', mouseout: 'onMouseOut', click: { fn: 'onClickButton', single: true }, confirmed: 'onConfirmed', scope: this }); } });