In extjs you can always extend an extjs class via the constructor()
. For classes derinving from Component
you can also extend via initComponent()
.
I am wondering why so many code extend via initComponent
, whereas constructor
seems to be the universal extension method. Does initComponent
offer clear advantage over constructor
?
First off, the ability to override via constructor
was added in a later version of Ext than initComponent
, so all code of a certain age would have to use initComponent. These days, you would still override initComponent if you want to do anything after the base class initComponent is called (constructor would be too early for this), but before the component is rendered. In many cases (like the most common, setting up configs), it does not practically matter either way and most people do whatever is most convenient. However, there are some cases where it matters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With