PDA

View Full Version : OOP question in Extjs



Baron89
9 Oct 2012, 7:48 PM
Hi all,i want to call a function that defined in the other class like the code show below,how should i make it?




ClassA = Ext.extend(ClassAUi, {
initComponent: function() {
ClassA.superclass.initComponent.call(this);
this.initActionHandler();
},
initActionHandler : function() {

this.getAddBtn().on('click',this.onClickAddBtn, this);

},
onClickAddBtn : function(){
//how can i call the function 'foo' that defined in classB?
},
getAddBtn : function(){

return Ext.getCmp("classA.add");
}
});
Ext.reg('ClassA',ClassA);



ClassB = Ext.extend(ClassBUi, {
initComponent: function() {
ClassB.superclass.initComponent.call(this);

},
foo : function(){
//do something
}
});
Ext.reg('ClassB',ClassB);

jorgeluislay
11 Oct 2012, 2:51 AM
I think it was something with createDelegate()

Jay Garcia explain this in some of his videos, maybe it was in this one. Just take a look, is very interesannt too: click me! (http://vimeo.com/9758715#)