Hi,
I have a question about the right approach to handle events in derived controllers. Here is my code:
Code:
Ext.define('ControllerA', {
extend: 'Ext.app.Controller',
refs: [
{
selector: 'configpanelselector',
ref: 'configpanel'
}],
init: function() {
var me = this;
this.control({
'configpanelselector': {
activate: function () {
me.loadData();
}
}
});
},
loadData():function{
me.getConfigpanelSelector().loadData();
}
getConfigpanelSelector:function () {
var p = Ext.ComponentQuery.query('#ControllerA' + 'configpanel');
return p[0];
}
}
Ext.define('ControllerB', {
extend: 'ControllerA',
init: function() {
this.callParent();
},
getConfigpanelSelector:function () {
var p = Ext.ComponentQuery.query('#ControllerB' + 'configpanel');
return p[0];
},
}
1. For ControllerA and ControllerA i am creating different configpanels (different instances) in different some other controller. (say, ViewA and ViewB respectively for ControllerA and ControllerB )
2. In ControllerA activate event fires for both views, which is fine. But in the loadData-> me.getConfigpanelSelector() always gets ControllerA' view (which is viewA).
3. To get around point #2, i ovveride getConfigpanelSelector() function in both controllers and returning the right instance by querying the component with id.
4. Now the questions:
a. load still gets called on both views as the event is there in two Controllers. How to avoid that?
b. is my approach of sub-classing correct?
Thanks
Santosh