For every view in my app, I am trying to create an fhActivate and fhDeactivate event for when views are created & destroyed so I can execute different necessary functions. In my main controller, after I create a view, I execute this:
view.fireEvent('fhActivate');
And in another controller, I am trying to listen for the event like this:
config: {
refs: {
rankings: {
selector: 'fhrankingspanel',
xtype: 'fhrankingspanel',
autoCreate: true
}
},
control: {
rankings : {
fhActivate: 'onRankingsActivate'
}
},
onRankingsActivate: function() {
console.log('activate');
}
}
The view is loaded fine, and the xtype is defined in that class like this:
alias: 'widget.fhrankingspanel'
But I get this error:
Uncaught TypeError: Cannot call method 'apply' of undefined
What am I missing?
UPDATE
I will also note, I have tried this within the control config object:
rankings : {
fhActivate: this.onRankingsActivate
}
And I also tried setting my ref to something simple:
rankings: 'fhrankingspanel'
It also helps if you do not wrap your methods within the config object. I noticed my stupid error when referring back to the docs here:
http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller
Once I changed that, and made my control method look like this, it worked: