Adding extra behavior to a function
Hi all,
I'm having a conceptual question on how to achieve the following:
Let's imagine I have a Toolbar:
Code:
MyToolbar = Ext.extend(Ext.Toolbar, {
initComponent : function() {
this.items = this.getToolbarItems();
MyToolbar.superclass.initComponent.call(this);
},
getToolbarItems: function () {
return [{
text: 'Original Button'
}];
}
});
But then I have another file that wants to augment this Toolbar adding an extra button. If I override the getToolbarItems then I lose the original item that was there:
Code:
Ext.override(MyToolbar,{
getToolbarItems: function () {
return [{
text: 'Additional Button'
}]
}
});
This will result in having a toolbar just with "Additional Button" instead of the 2 buttons.
I've read the following:
http://edspencer.net/2009/07/extover...ng-ext-js.html
But I don't really like the solution of closures because then I cannot incorporate the change inside of a component...
Is this the only way to achieve what I want?