1. #1
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default Class naming and namespace

    Class naming and namespace


    I having some problems with calling Ewa.Customer.CustomerGrid.init, from Ewa.Customer.
    When the user clicks a button this will call
    Ewa.Customer.activate()
    and it will call Ewa.Customer.CustomerGrid.init(). This doesn't work, but if I rename the class to Ewa.CustomerGrid it does.

    Could someone please explain what I'm doing wrong and tell me a little bit about namespace or a link that does?

    Ewa.Applayout.js
    Code:
    Ext.namespace('Ewa');
    
    // Creates the viewport
    Ewa.Applayout = function() {
        ...
        ...
    }();
    
    Ext.onReady(Ewa.Applayout.init, Ewa.Applayout);
    Ewa.Customer.js
    Code:
    Ext.namespace('Ewa');
    
    // Specifics for the Customer module
    Ewa.Customer = function() {
        return {
            init: function() {
                ...
                ...
            },
    
            activate: function() {
                addActionPanel();
                Ewa.Customer.CustomerGrid.init(); // Here is where I'm having problems
            }
        }
    }();
    
    Ext.onReady(function() { Ewa.Customer.init(), Ewa.Customer });
    Ewa.Customer.CustomerGrid.js
    Code:
    Ext.namespace('Ewa', 'Ewa.Customer');
    
    Ewa.Customer.CustomerGrid = function() {
        ...
        ...
        return {
            init: function() {
                ...
                ...
            }
    }();

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,164
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    What do you mean by doesn't work?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default


    Evant, thanks for replying.

    The function is not found.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,164
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Just try debugging like:

    Code:
    alert(Ewa);
    alert(Ewa.Customer);
    alert(Ewa.Customer.CustomerGrid);
    for (var i in Ewa.Customer.CustomerGrid)
       alert(i);
    Where abouts does it crash if you do something like that?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Aug 2008
    Location
    Gothenburg
    Posts
    157
    Vote Rating
    2
    Dr. Flink is on a distinguished road

      0  

    Default


    Code:
    alert(Ewa); // Alerts "[object Object]"
    alert(Ewa.Customer); // Alerts "[object Object]"
    alert(Ewa.Customer.CustomerGrid); // Alerts "Undefined"


    But, if I rename the last object to Ewa.CustomerGrid instead, I will get:
    Code:
    alert(Ewa); // Alerts "[object Object]"
    alert(Ewa.Customer); // Alerts "[object Object]"
    alert(Ewa.CustomerGrid); // Alerts "[object Object]"
    for (var i in Ewa.CustomerGrid)
       alert(i); // Alerts the public functions: "init" and "getGridDataStore"

  6. #6
    Ext User santosh.rajan's Avatar
    Join Date
    Sep 2007
    Location
    Kannur, Kerala, India
    Posts
    611
    Vote Rating
    0
    santosh.rajan is on a distinguished road

      0  

    Default


    Wrong ans sorry.
    Last edited by santosh.rajan; 8 Sep 2008 at 7:11 AM. Reason: Sorry wrong ans
    Make everything as simple as possible, but not simpler.
    - Albert Einstein

Thread Participants: 2