1

This question already has an answer here:

Say I have a component and child as below:

Component

<aura:attribute name="acc" type="Account"/>
<aura:handler name="change" value="{!v.acc}" action="{!c.valueChanged}" />

<c:myChild theAccount="{!v.acc}"/>

Component Controller

valueChanged: function(component, event,helper){
     console.log('I have changed');
}

Child Component

<lightning:input aura:id="bAddress" name="bAddress" label="Address"
    type="String" onchange="{!c.validateFields}" value="{!v.paymentProfile.Billing_Street__c}" required="true"/>

Child Controller

validateFields: function(component, event,helper){
   //..Do something on input change...
}

workAroundForChange: function(component, event,helper){
    var updatedAcc = component.get("v.theAccount");
    component.set("v.theAccount",updatedAcc);
}

When data is entered in the field on the child component, the Account sObject is updated on the child and the value is captured. However the change event for the parent sObject attribute does not fire

A workaround is to explicitly call the workAroundForChange function when I am done with data entry then this fires the change on the parent

Is it expected that changes to fields on the attribute sObject will not fire the change event and the entire attribute needs to be updated in order to fire the change event?

marked as duplicate by Praveen, Community Mar 13 '17 at 19:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    @Praveen - Thanks for that. Although it did not answer my question per say I guess that fact that the answer was the same as my workaround and no-one else chimed in I guess it is an expected behavior ahem bug... – Eric Mar 13 '17 at 19:35