ember.js - Sending an action from a child component and catching it in a parent component -
ember: 1.13.2
i can't seem working.
parent/child widget (gridster-container/gridster-widget)
{{#gridster-container}} {{#each model |widget|}} {{#gridster-widget sizex=widget.sizex sizey=widget.sizey action="addwidget"}} ... {{/gridster-widget}} {{/each}} {{/gridster-container}}
gridster-widget
export default ember.component.extend({ tagname : 'li', sizex : 1, sizey : 1, widget : null, didinsertelement : function() { var sizex = this.get('sizex'); var sizey = this.get('sizey'); //this.get('parentview').addwidget(this, sizex, sizey); //this.send('addwidget', this, sizex, sizey); //this.sendaction('action', this, sizex, sizey); //this.attrs.action(this, sizex, sizey); //this.get('gridstercontainer').send('addwidget', this, sizex, sizey); //this.action(this, sizex, sizey); this.sendaction('action', this, sizex, sizey); //i can see executing in debugger. } });
in gridster-container component have following action capture action.
actions : { addwidget : function(widget, sizex, sizey) { alert('worked'); //this never called } },
however action never called.
when yield need pass parentview
so template becomes:
{{#gridster-container |gridstercontainer|}} {{#each model |widget|}} {{#gridster-widget parentview=gridstercontainer sizex=widget.sizex sizey=widget.sizey action="addwidget"}} ... {{/gridster-widget}} {{/each}} {{/gridster-container}}
either or move gridster-widget
gridster-container.hbs
, ll have pass model {{#gridster-container widgets=model}}
, loop on them.
Comments
Post a Comment