sorting - Ember, run component method once when computed in controller has finished -
i'd call method once when computed in controller has finished.
here controller
:
import ember 'ember'; export default ember.arraycontroller.extend({ sortproperties: ['id:desc', 'id:asc', 'value:desc', 'value:asc'], sortedstats: ember.computed.sort('model', 'sortproperties'), actions: { sortby: function(sortproperties) { this.set('sortproperties', [sortproperties]); } } });
a template
:
<div><button {{action 'sortby' 'type:asc'}}>asc</button><button {{action 'sortby' 'type:desc'}}>desc</button></div> <h1>chart</h1> {{chart-bar width=500 height=200 series=sortedstats}}
and component
:
import ember 'ember'; export default ember.component.extend({ tagname: 'svg' draw: function() { // here draw chart }, init: function() { this._super(); }, onchange: function(){ console.log('onchange'); }.observes('series.[]') });
onchange
called many times model has properties sort. in example has been called 6 times , model contains array 5 properties. i'd call onchange
when computed.sort
in controller done.
any suggestions?
Comments
Post a Comment