Tuesday, February 28, 2012

I would like to use a static member named 'name' in my class

I would like to use a static member named 'name' in my class :

app.js
Ext.define("MyClass", {
      statics: {
            myVar: "toto",
            name: "could not be found"
      }
});
Ext.onReady(function(){
      console.log("MyClass.myVar = ", MyClass.myVar);
      console.log("MyClass.name = ", MyClass.name);
});

output
MyClass.myVar = toto
MyClass.name = 

But this member is not set as you can see if you execute the previous code. "Ext.Base" has a method 'getName()' and I think this is the source of my problem.
The only workaround I have found for the moment is the following:

app.js
Ext.namespace('MyClass');
MyClass.myVar = "toto";
MyClass.name = "Could not be found";
Ext.onReady(function(){
      console.log("MyClass.myVar = ", MyClass.myVar);
      console.log("MyClass.name = ", MyClass.name);
});

No comments: