AnsweredAssumed Answered

Accessing an nls string from an event

Question asked by kenbuja on Apr 6, 2017
Latest reply on Apr 7, 2017 by kenbuja

I've created a Toggle Button in the postcreate function

 

this.signin = new ToggleButton({
  showlabel: true,
  checked: false,
  label: this.nls.signin,
  onChange: this._onBtnSignInChanged
}, this.btnSignIn);

 

In the onChange event, I'd like to change the label to another string.

 

_onBtnSignInChanged: function (val) {
  if (val) {
    this.set('label', nls.signin);
  } else {
    this.set('label', nls.signout);
  }
}

 

However, this gives the error "Uncaught TypeError: Cannot read property 'signout' of undefined". What's the right way of accessing the nls to get that string? I suspect I have to use lang.hitch somewhere, but everywhere I've tried gives me another undefined error.

Outcomes