lundi 4 juillet 2016

Ember.js this.set() not working from inside action

Folks, I'm having some beginner problem and would love some assistance. This is in ember 2.6 if it makes any difference. Basically, I'm trying to change some text on the screen when the button is pressed inside a component. Here's the handlebars and component js code:

<h2>Stupid Button</h2>
<div>
  <form id="sign_in_form" >
    <button id="signin" type="submit">FIRE!</button>
    
  </form>
</div>

And the component's js code:

export default Ember.Component.extend({
  someTextThatShouldChange: 'Initial Value',
  actions: {
    triggerTheAction: (email, password) => { 
      alert('alerts just fine');
      this.set('someTextThatShouldChange', 'New value for text!');
    }    
  }
});

The error I get in console:

TypeError: _this.set is not a function

Really appreciate the help. I have a feeling I'm just not understanding something fundamental about Ember.




Aucun commentaire:

Enregistrer un commentaire