javascript - Ember action or this.get works only once -
i have index controller.
import ember 'ember'; export default ember.controller.extend({ actions: { reload() { console.log('click on button reload'); this.get('doreload'); } }, doreload: ember.computed(function() { console.log('do reload method'); // ajax action here. }), });
and button in template.
<button type="button" class="btn btn-secondary btn-sm" {{action 'reload'}}>reload</button>
when click on button first time, console.log()
contain 2 line of messages correctly.
click on button reload
reload method
but when click on button second time or more, console.log()
contain contain 1 line. doesn't call doreload
again.
click on button reload
how make this.get work every time click on action button?
computed properties cached until dependent properties changed. if want execute function not inside action create , call function.
export default ember.controller.extend({ actions: { reload() { console.log('click on button reload'); this.doreload(); } }, doreload: function() { console.log('do reload method'); // ajax action here. }, });
Comments
Post a Comment