Hello I am having a hard time refreshing a component. I want to totally recreate a sub child component from a child component(parent of the sub child). I am trying to implement as given in Refresh child by recreating it from the parent . But not able to do so.
Parent Component
<aura:component access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" controller="WspController">
<!--All attributes-->
<!--Child Component-->
<c:questionSectionPolitic aura:id="childQuestion"
qstList="{!qstList}"
recordId="{!v.recordId}"
questionA="{!v.questionA}"
questionB="{!v.questionB}"
questionC="{!v.questionC}"
questionD="{!v.questionD}"
questionE="{!v.questionE}"
questionF="{!v.questionF}"
questionG="{!v.questionG}"
questionH="{!v.questionH}"
questionI="{!v.questionI}"
questionJ="{!v.questionJ}"
questionK="{!v.questionK}"
questionL="{!v.questionL}"
/>
<button type="button" aura:id="saveAndReturn" class="slds-button slds-button--neutral slds-button slds-button--brand slds-hide" onclick="{!c.saveAndReturn}" >Save and return
</button>
</aura:component>
Parent Controller
saveAndReturn: function (component,event,helper){
// Some changes
$A.createComponent(
'c:questionSectionPolitic', {
"aura:id":"childQuestion",
"qstList": component.get("v.contactList"),
"recordId": component.get("v.recordId"),
"questionA": component.get("v.questionA"),
"questionB": component.get("v.questionB"),
"questionC": component.get("v.questionC"),
"questionD": component.get("v.questionD"),
"questionE": component.get("v.questionE"),
"questionF": component.get("v.questionF"),
"questionG": component.get("v.questionG"),
"questionH": component.get("v.questionH"),
"questionI": component.get("v.questionI"),
"questionJ": component.get("v.questionJ"),
"questionK": component.get("v.questionK"),
"questionL": component.get("v.questionL")
}
function(newComponent, status, errorMessage){
if (status === "SUCCESS") {
var body = component.find("childQuestion");
body.push(body, newComponent);
}
else if (status === "INCOMPLETE") {
console.log("No response from server or client is offline.")
// Show offline error
}
else if (status === "ERROR") {
console.log("Error: " + errorMessage);
// Show error message
}
}
);
}
Is this approach right ?
PS: There is no init method I can use in the Child component.