You need to sign in to do that
Don't have an account?
Reusing Functions Salesforce Lightning
Is there a way for one component to reference the functions in another without embedding?
If I have to embed the component, how do I reference there parent function from a child component and vice versa?
If I have to embed the component, how do I reference there parent function from a child component and vice versa?
You can do this 2 ways :
Create a parent component and extend in child component
<aura:component implements="forceCommunity:availableForAllPageTypes" controller="PC_CreateCaseController" extends="c:PC_CreateCasePage" access="global">
This was you can call parent component method
Second way is to use application level events, create 2 events and fire a event from child and handle it in parent upon event received call the method of your choice and when finished fire a event from parent that gets handled in child. You can transport data through event's attribute.
Thanks
Second Option
There is no parent event and child event , there is only application event, parent and child components both can fire a event and both can handle a event, to fire a parent method from child simply fire a event from child , handle it in parent and once it is captured in parent call respective method.
First option:
You do not need to add super keyword just call the method as its in same component
Just to add, You also need add extensible attribute at aura:component (parent) level.
Ex:
<aura:component extensible="true" /> <--- parent component
Thanks
Brahma