1. #1
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    557
    Vote Rating
    25
    estesbubba will become famous soon enough estesbubba will become famous soon enough

      0  

    Default [B1] Ext.create() params automatically put into config{}?

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


    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.

    Code:
    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
    })

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,074
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Here is runnable code:

    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.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1