The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Dumas (2) [Avatar] Offline
#1
Hello Jay!

I just red the part of the book about application design.
On page 441 in "Listing 16.16 The FormPanelBaseCls template" you define a new constructor function.

But why do you have to define the constructor at all?

That should work as well as far as I can see....
TKE.form.FormPanelBaseCls = Ext.extend(Ext.form.FormPanel, {
newMethod1: function() {...}
});

best regards,
Roland
jesus.garcia (463) [Avatar] Offline
#2
Re: Why defining a new constructor in "Listing 16.16 FormPanelBaseCls tmpl"?
Hi roland,

The way JavaScript prototypal inheritance works, and how Ext JS actually creates new "classes", you are creating a constructor.


var myCls = Ext.extend(Ext.Component, {/* overrides */}); <-- actually has to create a constructor for you.

For all intents and purposes, myCls is a new constructor. I.e. you must use the 'new' keyword to instantiate a new instance of myCls.

Does this help?
Dumas (2) [Avatar] Offline
#3
Re: Why defining a new constructor in "Listing 16.16 FormPanelBaseCls tmpl"?
Hi!


I know that actually in js there is nothing like a class, so ExtJS provide functions like Ext.extend so have prototypes act like classes....

My question was a different one. In your example myCls would use the constructor from Ext.Component.
So why do you define a new constructor for the FormPanel example in the book?
(Hope I didn't toally miss somehting smilie)

thx
Roland