-
7 Sep 2008 7:09 AM #1
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
Ewa.Customer.jsCode:Ext.namespace('Ewa'); // Creates the viewport Ewa.Applayout = function() { ... ... }(); Ext.onReady(Ewa.Applayout.init, Ewa.Applayout);
Ewa.Customer.CustomerGrid.jsCode: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 });
Code:Ext.namespace('Ewa', 'Ewa.Customer'); Ewa.Customer.CustomerGrid = function() { ... ... return { init: function() { ... ... } }();
-
7 Sep 2008 4:39 PM #2
What do you mean by doesn't work?
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
8 Sep 2008 2:34 AM #3
Evant, thanks for replying.
The function is not found.
-
8 Sep 2008 2:38 AM #4
Just try debugging like:
Where abouts does it crash if you do something like that?Code:alert(Ewa); alert(Ewa.Customer); alert(Ewa.Customer.CustomerGrid); for (var i in Ewa.Customer.CustomerGrid) alert(i);
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
8 Sep 2008 3:20 AM #5
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"
-
8 Sep 2008 7:04 AM #6
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


Reply With Quote