bensiu
bensiu

Reputation: 25604

Extjs 5 - static function call other static function from same class

I have code like this:

Ext.define( 'someClass', {

   statics : {

      methodA   : function( ) { return 'A'; },
      methodAB  : function( ) {

        var A = this.methodA();
        return A + 'B';
      }
   }
} );

I have problem with accessing static methodA. Can someone help me what would be a proper way to do it ?

Upvotes: 2

Views: 2563

Answers (1)

Tom R
Tom R

Reputation: 48

you should call statics using the fully qualified className.methodName() syntax. 'this' inside a static is not going to be what you think it is. For example, if called from an event handler it will probably be the 'window' object, which certainly doesn't have a methodA() method. In other cases 'this' may be the prototype. In that case you may get away with this syntax but it is misleading and likely to cause future bugs.

Upvotes: 1

Related Questions