Say I have a component and child as below:


<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");

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?

  • 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