PDA

View Full Version : Scope property



luca.santaniello
30 Nov 2009, 2:36 AM
Hi,

I extended Ext.Panel...



MyComponent = Ext.extend(Ext.Panel,
{...

constructor: function(config)
{
MyComponent.superclass.constructor.apply(this, arguments);

this.init();
},

init: function()
{
//map is object
map = ....
}

afterRender: function()
{
//this.map is null here !!! Why?
}

}


My problem is that property map is undefined in my afterRender method.

What's my error code?

Thanks

Luca

30 Nov 2009, 7:21 AM
you're setting the variable "map", not "this.map"

luca.santaniello
1 Dec 2009, 12:07 AM
you're setting the variable "map", not "this.map"

I wrong message...

My code is:



MyComponent = Ext.extend(Ext.Panel,
{...

constructor: function(config)
{
MyComponent.superclass.constructor.apply(this, arguments);

this.init();
},

init: function()
{
//map is object
this.map = ....
}

afterRender: function()
{
//this.map is null here !!! Why?
}

}

Thanks

Animal
1 Dec 2009, 12:25 AM
If you are using renderTo, then the Component constructor renders, which will call onRender. In this case, your init will not have been called.

Mike Robinson
1 Dec 2009, 7:43 AM
It is always a good idea to set (FireBug) breakpoints at all of the routines that you expect to be called, to observe if they are actually being called.

It's also helpful to do the same thing with other examples that do work as you expect them to. The "stack trace" panel of the debugger will show you the entire chain of calls leading up to that point, so that you can see for yourself exactly what calls what, and when.

"Use the Source, Luke!"