2

I have a generic card lightning component which displays some data according to the attributes provided. I have created the following hierarchy.

<compA>
  <myComp/>
  <compB>
     <myComp/>
     <myComp/>
     <compC/>
  </compB>
</compA>

The generic component is mycomp and the attributes provided will be different for each instance will be different. So suggestions how I can achieve the following:

  1. A change in the attribute for one instance should not affect the attributes for the other instances.
  2. Hiding a component by adding slds-hide to the container in the inner dom(this can be done calling a function of the child using the particular aura:id but for some reason the other instances were also affected despite having different aura:id)
  3. An event fired from say compC (compoent type or application type?) should only be handled by the components inside compB and not the one outside.

1 Answer 1

2

First of all, if you define event as Component event, only parent components will receive this event.

Also you can distinguish events by event name.

You can pass desired component name or index or version and then check it inside the component if its version or name or index matches the parameter.

=============================================

Expanded comment

<compA>
  <myComp inside="false"/>
  <compB>
     <myComp inside="true"/>
     <myComp inside="true"/>
     <compC/>
  </compB>
</compA>

and code

if ( component.get('v.inside') ) {
   //execute the logic needed
}
2
  • so if I fire the event for compC... ill have to add the handler in compB and then from compB call the respective function in mycomp inside compB. But the problem is... I need to pass and set an attribute(through the event) from compC to the mycomp inside compB but not on the one outside compB. Jul 19, 2017 at 13:04
  • Actually there are several possible ways to achieve that and I believe I mentioned them in my answer. I have now also updated and expanded my answer to explicitly display one of the possible solution.
    – Patlatus
    Jul 19, 2017 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .