Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to clear input helper after action is handled?

Tags:

ember.js

I'm using Ember v 1.13.8

I have input helper:

{{input type="text" value=newData action="addNewItem"}}

and action handler:

actions: {
    addNewItem: function(value) {
      this.get('personList').pushObject({name: value});
      this.set('newData', '');
    }
}

As you can see in order to clear input I have variable in controller where I store temporary value. I made input helper dependent on it and this approach works, but I wonder may be there is Ember way of doing this?

like image 974
SuperManEver Avatar asked Mar 14 '23 11:03

SuperManEver


1 Answers

Your approach is correct. The only more Ember way I can see is using new JavaScript syntax when declaring function:

actions: {
    addNewItem(value) {
      this.get('personList').pushObject({name: value});
      this.set('newData', '');
    }
}
like image 89
Daniel Kmak Avatar answered Apr 01 '23 07:04

Daniel Kmak