PDA

View Full Version : [B1] Ext.create() params automatically put into config{}?



estesbubba
3 Feb 2012, 12:30 PM
In PR4 when you did an Ext.define(), the params would go into config{} if defined there otherwise at the class level. In B1 it appears everything ends up in config{} even if it wasn't defined there. Just making sure I'm not missing something before I go and change all our code.

Here is an example of what I'm talking about.



Ext.define('App.view.A', {


a: 1,
b: 2,

config: {
c: 3,
d: 4
}

initialize: function() {
this.a is 1
this.b is 2
this.config.a is 10
this.config.b is 11
this.config.c is 20
}
});


Ext.create('App.view.A', {
a: 10,
b: 11,
c: 20
})

mitchellsimoens
4 Feb 2012, 6:46 AM
Here is runnable code:


Ext.define('App.view.A', {
a: 1,
b: 2,

config: {
c: 3,
d: 4
},

constructor : function(config) {
this.initConfig(config);

this.callParent([config]);

//there is no this.getA or this.getB
console.log(this.a); //returns 1
console.log(this.b); //returns 2
console.log(this.getC()); //returns 20
console.log(this.getD()); //returns 4
}
});

Ext.setup({
onReady : function() {

var A = Ext.create('App.view.A', {
a: 10,
b: 11,
c: 20
});

console.log(A.a); //returns 1
console.log(A.b); //returns 2

}
});

So you can see, a and b are kind of private and the reason there is no getA or getB method is because they aren't in the config object. The a and b when you use Ext.create are basically lost and if you look after using Ext.create, the a and b properties are what they were in the Ext.define.