ember.js - Emberjs 1.13.0—Call Action of Component -
i have such component:
app.mynicecomponent = ember.component.extend({ actions: { save: function () { … } } });
the template it:
<h1>my nice component</h1> {{ yield }}
anywhere in template:
{{#my-nice |mn| }} … <a onclick={{ action 'save' }}>save</save> {{/my-nice}}
clicking on link make ember try trigger action in routes controller. guess because version using here old, there way make ember call components action, or hand on function reference link, called?
in component, designed have child components, manage so:
app.achildcomponent = ember.component.extend({ targetobject: em.computed.alias('parentview'), task: '', action: 'onchildclick', //present action in parent compoent click: function(){ this.sendaction('action', this.get('task')); } })
in hbs that:
{{#my-nice}} {{#a-child task="do this"}} {{/my-nice}}
in case love make ember trigger compoents actions, without way on controller…
thanks in advance.
@philipp, can use action helper pass action component anywhere(pass action "actionname"
parameter in yield). eg:- in case <h1>my nice component</h1> {{yield (action "save")}}
{{#my-nice |saveaction| }} … <a onclick={{ action saveaction }}>save</save> {{/my-nice}}
Comments
Post a Comment