diealp
March 29, 2014, 6:02pm
1
Hi all,
I have a component which call himself…
this is the template calling the component:
discussione.hbs
{{messaggi-discussione messaggi=this.messaggi inviarisposta="inviaMessaggio"}}
and this is the component template calling himself using other parameters:
components/messaggi-discussione.hbs
{{messaggi-discussione messaggi=messaggio.risposte inviarisposta="inviaMessaggio"}}
this is the action section in the component
discussione_controller.js
actions: {
inviaRisposta : function (msgcall) {
console.log('COMPONENT inviaRisposta');
this.sendAction('inviarisposta', risposta);
}
}
and this is the action section in the controller
actions: {
inviaMessaggio: function (datimessaggio) {
console.log('CONTROLLER inviaMessaggio');
}
}
the problem is that the controller action inviaMessaggio is called only from the first level component… nested components doesn’t bubble to the controller… why?
Surely im making something wrong…
I am having trouble replicating your issue. Ember Latest - JSFiddle - Code Playground Modify this jsfiddle to illustrate your problem.
diealp
March 30, 2014, 10:52pm
3
Just modified to reply my situation… in the jsfiddle it works… i have to check something in my code…
diealp
April 4, 2014, 6:54am
4
After some days I check my code… and now it works…
The problem was the #each iteration inside the component
I was doing it:
Call the component from my template
{{messaggi-discussione messaggi=this.risposte}}
The component iterate itself inside of him
{{#each messaggio in messaggi}}
{{messaggi-discussione messaggi=messaggi.risposte}}
{{/each}}
Now I modify the code like this:
Iterate the component from the template:
{{#each risposta in this.risposte}}
{{messaggio-discussione messaggio=risposta}}
{{/each}}
And the component iterate itself inside of him
{{#each risposta in messaggio.risposte}}
{{messaggio-discussione messaggio=risposta}}
{{/each}}
And it works… note that messaggio is the singular for messaggi, risposta is the singular for risposte
Now the actions bubble to the controller.
Thanks for the support
1 Like