function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dhaker HassineDhaker Hassine 

Two components handling the same event from the same lightning component

Hello everyone, 

I declared two lightning components "calend" et "SignIn" in the same lightning component "MainComponent". And I make SignIn as the sender of an event (Type = APPLICATION) , and the two others as listeners.

With the same code in hundleaction, I've got a result with MainComponent, but Calend doesn't recieve anything. How can I resolve this problem. 
Here MainComponent code : 
 

<aura:component >
    <aura:attribute name="variable" type="boolean" default="False"/>
   <aura:handler name="connResource" event="c:LoginEvent" action="{!c.handleLoginEvent}"/>
	 <aura:if isTrue="{!v.variable == False}">
         <c:SignIn/>
    <aura:set attribute="else">
       <c:Calend/>
    </aura:set>
  </aura:if> 
</aura:component>
Danish HodaDanish Hoda
Hi Dhaker,
Since you are using aura:if, might be that your Calend cmp has not been rendered on the DOM to recieve the event.
Dhaker HassineDhaker Hassine
Hi Danish, I don't think, because even if I put it in the same clause with SignIn component, it doesn't work 
Danish HodaDanish Hoda
Hi Dhaker,
Please share your code here.
Dhaker HassineDhaker Hassine

Hello Danish, 

I make an attribute in Calend component, and I found a way to set its value from the parent component, like that 

<aura:component >
    <aura:attribute name="variable" type="boolean" default="False"/>
    <aura:attribute name ="login" type="string" default =''/>
   <aura:handler name="connResource" event="c:LoginEvent" action="{!c.handleLoginEvent}"/>
	 <aura:if isTrue="{!v.variable == False}">
         <c:SignIn/>
         
    <aura:set attribute="else">
        
      <c:Calend childAttribute="{!v.login}"/>
        

       <c:Calend/>
       
    </aura:set>
  </aura:if> 
</aura:component>

And it rks normally!