ExtJS class/component constructor not running

There are a couple of syntaxs for extending a ‘class’ with the Ext library. I prefer the following syntax.

MyNewForm = Ext.extend(Ext.form.FormPanel,{

constructor:function(config){
…..
MyNewForm.superclass.constructor.call(this,config);
….
},

newMethod:function(){
}
})

 

I had a strange problem today. I had two almost identical classes. In one I could get a console log statement in the constructor to output. In the other I could not get it to work. The problem was I also didn’t get an error. The problem component would initialize and I could see it in the firebug dom tree.

Took me about 20 minutes to figure out the problem. Turns out I typed ‘construtor’ on the second class. Since Ext automatically calls the parent class constructor (if you do not override) I wasn’t getting an error.

Crazy how little typos can waste a lot of time…. so if you have this same problem, make sure you actually typed what you though you typed.

Advertisement

Leave a Comment

Filed under ExtJS, Javascript

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s