javascript - Bubbling action event with custom Object from component to controller using Morris.js graph in Ember component -
i'm implementing basic ember component render morris.js line graph. need listen click event on morris , pass action.
app.progressgraphcomponent = ember.component.extend( { graph: null, tagname: 'div', rendergraph: function() { this.graph.setdata(this.get('progress')); }.observes('progress'), didinsertelement: function() { var element = this.get('element').id; var self = this; this.graph = new morris.line( { element: element, xkey: 'date', ykeys: ['amount', 'increase'], labels: ['amount', 'increase'], resize: true, smooth: false, parsetime:false }).on('click', function(i, row){ self.set('clicked', row); self.sendaction('gotosession'); }); } });
in controller, when gotosession
event triggered, passes in component
object. i'd prefer if passed in row
object.
is correct way bubble action
row
parameter?
it might more preferable send row object action itself. ember.js components allow sending actions arguments included. example:
this.sendaction('gotosession', row);
which translates in action (that either exists in controller or route):
actions: { gotosession: function(row) { // manipulate morris row } }
learn more sending actions outside of component in ember.js components guide.
Comments
Post a Comment