2

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 ?

2
  • 2
    You have a typo: it should be function instead of funcyion. Commented May 3, 2015 at 14:42
  • What do you mean you have a problem? fiddle.sencha.com/#fiddle/m7p Commented May 3, 2015 at 21:51

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.