You need to sign in to do that
Don't have an account?
Lightning Practice
can't able to handle the event from parent to child
Hi All,
Please correct me cannot able to handle event from parent to child.
Registered event in parent as
Event is firing well but cannot able to handle in child component
Controller.js in child component
event
please suggest what is wrong?on button click am firing child component
Thanks.
Ram
Please correct me cannot able to handle event from parent to child.
Registered event in parent as
<aura:registerEvent name="projectSelected" type="c:project_Phase_holdevent"/>Controller.js to fire an event
var proj=component.find('project').get('v.value'); var ProjectPhasesEvent = $A.get("e.c:project_Phase_holdevent"); ProjectPhasesEvent.setParams({"project": proj}); console.log('event fired'+proj); ProjectPhasesEvent.fire();
Event is firing well but cannot able to handle in child component
<aura:handler event="c:project_Phase_holdevent" action="{!c.setSelectedProjectId}"/>
Controller.js in child component
setSelectedProjectId : function(component, event, helper) { var selectedProject = event.getParam("project"); alert(selectedProject); }
event
<aura:event type="APPLICATION" > <aura:attribute name="project" type="string" /> </aura:event>
please suggest what is wrong?on button click am firing child component
Thanks.
Ram
Hi Abdul ,
Thanks for the time taken for this issue,
The solution is when we fire application event parent and child component should be in one lightning page.Its Passing now
Thanks ,
Ram .
All Answers
You Parent should be handling the event, and you should be firing the event inside the child, meant Register the event inside the child and move the button inside it. Then give a try
Moving button inside child component doesnot meets my criteria as am doing on choosing Parent record displaying its childs in child Component
Thanks ,
Ram
<c:childcomponent attributname = 'parent value'
That doesn't work for my requirement.
Thanks,
Ram
https://developer.salesforce.com/forums/?id=906F0000000MK0TIAW
Event is firing and am getting ID too.can you please specify where it is ?
Thanks ,
Ram
ParentCmp Controller.js
Childcmp
controller.js
Event
Thanks,
Ram
- In the Parent Component in the end place this code
Try now it should fire the EventThis seems little funcky and seems like a bug on the salesforce end but it work. I guess this way telling linking the parent component to child from the handling perpective which automatically happens vice versa.
Let me know if this worked.
Hi Abdul ,
Thanks for the time taken for this issue,
The solution is when we fire application event parent and child component should be in one lightning page.Its Passing now
Thanks ,
Ram .