Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  25] [ 3]  / answers: 1 / hits: 20996  / 14 Years ago, sat, july 3, 2010, 12:00:00

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?


More From » inheritance

 Answers
21

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.


[#96346] Wednesday, June 30, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
meliashelbief

Total Points: 179
Total Questions: 94
Total Answers: 116

Location: Romania
Member since Mon, Jun 6, 2022
2 Years ago
;