Threaded View

  1. #1
    Sencha User raskri's Avatar
    Join Date
    Dec 2008
    Location
    Stavanger, Norway
    Posts
    73
    Vote Rating
    0
    Answers
    1
    raskri is on a distinguished road

      0  

    Default Answered: My app runs fine before I compile it

    Answered: My app runs fine before I compile it


    I have a problem. To explain my problem:
    Code:
    var panel = new MyApp.view.Test({foo:'bar'});
    and in my Test.initialize function I do this:
    Code:
    Ext.define('MyApp.view.Test', {    extend: 'Ext.Panel',
        initialize: function() {
            this.callParent(arguments);
            console.log(this.foo);
        }
    });
    I get undefined echoed out in the console, only after I compile... Any thoughts?

    I'm using Sencha Cmd v3.0.2.288 on Windows 7 and Sencha Touch 2.1.1

  2. In your panel definition you should really have

    Code:
    Ext.define('MyApp.view.Test', {
        extend : 'Ext.Panel',
    
        config : {
            foo : null
        },
    
        initialize : function () {
            this.callParent(arguments);
            
            console.log(this.getFoo());
        }
    });
    and also use the getFoo method instead of trying to use the foo property as there won't be one. This is the proper way to add configs.

Thread Participants: 1