onites. I have encountered an issue with updating a record from a child sub-component. The parent component passes the attribute when it instantiates the child component but whenever there is an edit in a child's lightning:input, the change does not reflect in the parent after the COMPONENT event has fired. Any help would be greatly appreciated!
Event
<aura:event type="COMPONENT">
<aura:attribute name="updateField" type="String" />
</aura:event>
Parentcmp.cmp
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
layoutType="FULL"
targetRecord="{!v.record}"
targetFields="{!v.simpleRecord}"
targetError="{!v.recordError}"
mode="EDIT"/>
<aura:handler name="componentEventFired"
event="c:ContentEditorEvent"
action="{!c.handleComponentEventFired}" />
<c:childcmp docName = "{!v.simpleRecord.Name}"
ParentController.js
handleComponentEventFired : function(cmp, event) {
var updateField = event.getParam("updateField");
cmp.set("v.simpleRecord.Name", updateField);
},
Childcmp.cmp
<aura:attribute name="docName" type="String" />
<aura:registerEvent name="componentEventFired" type="c:ContentEditorEvent" />
<lightning:button label="Save" variant="brand" onclick="{!c.fireComponentEvent}" />
ChildController.js
fireComponentEvent : function(cmp, event) {
var docName = cmp.get("v.docName");
var cmpEvent = cmp.getEvent("componentEventFired");
cmpEvent.setParams({"updateField" : docName});
cmpEvent.fire();
},
I just don't get why this doesn't update the record.