I have a child component inside my parent component as below:

<aura:iteration items="{!v.articolo.items}" var="item">
    <c:RigaTabellaItemsKit item="{!item}" PicklistStatoKit_SelVal="{!v.PicklistStatoKit_SelVal}" aura:id="item_in_kit"/>

During some operation inside the Helper of the parent component, I should call a function defined inside the child component.

Helper (Parent):

var pesi_value = component.get("v.pesi");
var articoloKit = component.get("v.articolo");
var itemsInKit = articoloKit.items;
var value1 = 2.0;

for (var i = 0; i < pesi_value.length; i++){
    itemsInKit[i].voce.Prezzo_totale__c = value1 * pesi_value[i];
    //here I should call a function inside the child component.

Assume that the function which I want to call is as described inside the Helper of the child as below:

calcolaRicarico : function(component, event, helper) {
    helper.calcolaRicarico(component, event);

How could I do that?


you can call using aura:method by using aura:id

<c:RigaTabellaItemsKit  aura:id="item_in_kit"/>

Helper (Parent):


In child:

<aura:method name="calcolaRicarico" action="{!c.calcolaRicarico}" />
| improve this answer | |
  • I added the line you mentioned to the child. and in my parent (helper) I called component.find("item_in_kit").calcolaRicarico(); But it gave me error that this function does not exist. – ReshaD Jan 17 '17 at 15:47
  • Did you handled <aura:method>in child component .As you mentioned you want to call child helper method... you need to call helper method from child controller. – vignesh Jan 17 '17 at 16:02
  • Yes the method is already defined if you meant defining it by handling – ReshaD Jan 17 '17 at 16:06
  • Nope.I meant to define a method in child component. for parent component to call a method on a child component .. – vignesh Jan 17 '17 at 16:19
  • Yep, it is defined already. – ReshaD Jan 17 '17 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.