Skip to content

Instantly share code, notes, and snippets.

@dsharrison
Last active October 9, 2016 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsharrison/5e686c8e430a8ead77c91f2f4401ca3a to your computer and use it in GitHub Desktop.
Save dsharrison/5e686c8e430a8ead77c91f2f4401ca3a to your computer and use it in GitHub Desktop.
A reduced test case for the issues with <lightning:input /> bindings
<aura:component implements="force:appHostable">
<!-- public attributes -->
<aura:attribute name="myObj" type="Account" default="{Name: '', Type: ''}" access="PUBLIC" />
<!-- body markup -->
<c:lightningInputReproFields record="{!v.myObj}" />
<lightning:button label="Update Object" onclick="{!c.updateObj}" />
<lightning:button label="Update Name" onclick="{!c.updateName}" />
</aura:component>
({
updateObj: function (component, event, helper) {
var rand = Math.floor(Math.random() * 99);
var newObj = {
'Name': 'new name ' + rand,
'Type': 'new type ' + rand
};
component.set('v.myObj', newObj);
},
updateName: function (component, event, helper) {
var rand = Math.floor(Math.random() * 99);
component.set('v.myObj.Name', 'new name ' + rand);
}
})
<aura:component >
<!-- public attributes -->
<aura:attribute name="record" type="Account" default="{Name: '', Type: ''}" access="PUBLIC" />
<!-- body markup -->
<lightning:input name="name" type="text" label="Name" value="{!v.record.Name}" />
<lightning:input name="type" type="text" label="Type" value="{!v.record.Type}" />
</aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment