I have a lightning component in which I am trying to open up a child record in edit mode in a modal popup using $A.createComponent and calling force:recordEdit.This lightning component is added as a separate tab on the Lightning page of the parent object where I pass the child record id to $A.createComponent.
The issue here is that even before the $A.createComponent completes the rendering of the child record details in the modal popup, the modal popup gets displayed with the header but with an empty body.But as soon as the force:recordEdit is complete, the popup comes up correctly.
Below is the image when user clicks on edit:
Below is the complete popup which comes up correctly after rendering is complete:
Below is the javascript controller method in which I have explicitly made sure that the modal popup gets displayed only when the callback is executed and has state='SUCCESS':
onSingleSelectChange: function(component, event, helper) {
var operation = event.getSource().get("v.value");
//alert('operation is '+operation);
var resource = event.getSource().get("v.label");
var recId = resource[0].fId;
//alert('record id is '+recId);
if(operation == 'Edit'){
component.set("v.BookingId",recId);
$A.createComponent('force:recordEdit',
{
'aura:id': 'edit',
'recordId': recId
},
function(edit, status, errorMessage){
if (status === "SUCCESS") {
alert('testing');
component.set('v.edit', edit);
component.set("v.cssStyle", ".forceStyle .viewport .oneHeader.slds-global-header_container {z-index:0} ");
component.set("v.showBookingModal",true);
}
}
);
}
else if(operation == 'Delete'){
component.set("v.BookingId",recId);
component.set("v.showConfirmDelete",true);
component.set("v.cssStyle", ".forceStyle .viewport .oneHeader.slds-global-header_container {z-index:0} ");
}
},
Ideally the popup should be displayed only when the force:recordEdit is complete and we have state='SUCCESS'.I am really not sure what I am missing here.Please help.