I've built nested lightning components available for a contact page. There are three components: the Pane which sits on the record home page this has three tabs one tab is a text field, the other two tabs are used to display different nested components. One of these components is a list of tasks. Clicking on the subject of a task in the list fires an force:editRecord
event. This successfully brings up the window and any changes are saved. However it does not refresh the view. I've tried accomplishing this in a couple ways.
I tried implementing the method suggested here, which handles a force:refreshView
event and uses aura:dependency
.
I also tried handling a force:saveRecordSuccess
however the associated controller code was not being accessed as evidenced by no console logs.
I've attempted putting the handlers in both the child component and the parent Pane component with no difference in behavior.
Lastly I tried window.location.reload();
after firing the editRecord
event but it reloads the page before bringing the edit page up.
List component markup
<aura:component controller="AccountDevelopmentTaskController" access="global" implements="force:appHostable,flexipage:availableForAllPageTypes,force:hasRecordId">
<aura:attribute name="challenges" type="Task[]" access="GLOBAL"/>
<aura:attribute name="id" type="String" access="GLOBAL"/>
<aura:handler name="init" value="{!this}" action="{!c.start}"/>
<aura:dependency resource="markup://force:editRecord" type="EVENT"/>
<aura:handler event="force:refreshView" action="{!c.start}"/>
<div class="slds-container--fluid">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<thead>
...
</thead>
<tbody>
<aura:iteration var="chlng" items="{!v.challenges}">
<tr>
<th scope="row" data-label="Challenge">
<div class="slds-truncate slds-text-link" title="">
<div data-record="{!chlng.Id}" onclick="{!c.showEditPanel}">
<ui:outputText value="{!chlng.Subject}" class="slds-text-link_reset" />
</div>
</div>
</th>
...
</tr>
</aura:iteration>
List component controller
start : function(component,event,helper) {
var id = component.get("v.id");
var action = component.get("c.loadChallenges");
action.setParams({"tId":id});
action.setCallback(this,function(response){
var tasks = response.getReturnValue();
component.set("v.challenges",tasks);
});
$A.enqueueAction(action);
},
showEditPanel : function(component,event,helper){
var editRecordEvent = $A.get("e.force:editRecord");
var selectedItem = event.currentTarget;
var recId = selectedItem.dataset.record;
component.set("v.currParamId",recId);
editRecordEvent.setParams({
"recordId" : recId
});
editRecordEvent.fire();
}
Here is the Pane component compacted to the relevant bits:
<aura:component controller="AccountDevelopmentTaskController" access="global" implements="force:appHostable,flexipage:availableForRecordHome,force:hasRecordId">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="msg" type="String" access="GLOBAL"/>
<lightning:tabset class="slds-box" >
...
<lightning:tab label="Challenge">
<c:ADChallengeList id="{!v.recordId}" /> ...