Skip to content

Instantly share code, notes, and snippets.

@forcetrekker
Last active February 25, 2021 13:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save forcetrekker/26fd194a0e505760913e9119e33a9efa to your computer and use it in GitHub Desktop.
Save forcetrekker/26fd194a0e505760913e9119e33a9efa to your computer and use it in GitHub Desktop.
How to create a custom rerender on a lightning component bundle? 213376
<aura:component description="TestChild">
<aura:registerEvent name="fromModal" type="c:Event_213329"/>
This is for testing
<lightning:button label="Call Parent"
onclick="{!c.callParent}" />
</aura:component>
({
callParent: function (component, event, helper) {
var evt = component.getEvent('fromModal')
.setParams({
"message" : "A component event fired me. " +
"It all happened so fast. Now, I'm here!" })
.fire();
}
});
<aura:event type="Component" description="Event template">
<aura:attribute name="message" type="String"/>
</aura:event>
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:appHostable,force:hasRecordId">
<aura:handler name="fromModal" event="c:Event_213329"
action="{!c.fromModal}" />
<aura:attribute name="message" type="String"/>
<lightning:button label="ShowModal"
onclick="{!c.showModal}" />
<hr/>
message: {!v.message}
<lightning:overlayLibrary aura:id="overlayLib"/>
</aura:component>
({
showModal: function (component, event, helper) {
$A.createComponent("c:Child_213329", {
"fromModal": component.getReference("c.fromModal")
},
function(content, status, error) {
if (status === "SUCCESS") {
component.find('overlayLib').showCustomModal({
header: "Child",
body: content,
showCloseButton: true
});
} else {
throw new Error(error);
}
});
},
fromModal: function (component, event, helper) {
var message = event.getParam("message");
console.log('message from modal', message);
component.set("v.message", message);
},
genericCalled: function (component, event, helper) {
alert("genericCalled");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment