the following code is causing an infinite loop in my lightning component when I click the ui:button. Checking debug logs, nothing ever goes to the apex controller.
.cmp layout
<aura:attribute name="account" type="Account" default="{ 'sobjectType': 'Account'}"/>
<aura:attribute name="deliveryMethod" type="string[]" />
<ui:inputSelect value="{!v.account.Delivery_Method__c}" multiple="true">
<aura:iteration items="{!v.deliveryMethod}" var="p">
<ui:inputSelectOption text="{!p}" label="{!p}"/>
</aura:iteration>
</ui:inputSelect>
<div>
<ui:button label="Update Preferences" press="{!c.saveAccount}" />
</div>
js controller:
saveAccount : function(component,event,helper){
var a = component.get("v.account");
var saveAction = component.get("c.saveAccount");
saveAction.setParams({
acct : a
})
saveAction.setCallback(this,function(res){
console.log('callback');
});
$A.enqueueAction(saveAction);
}
and my Apex Controller:
@AuraEnabled
public static ResponseDto saveAccount(Account acct){
try{
upsert acct;
}catch(Exception e){
ResponseDto res = new ResponseDto(false, 'System Error has occurred:' + e.getMessage());
return res;
}
// Create Object for response as Success Completion. Insert the return value to Map
ResponseDto res = new ResponseDto(true, '');
return res;
}
public class ResponseDto {
@AuraEnabled public Boolean isSuccess { get; set; }
@AuraEnabled public String message { get; set; }
@AuraEnabled public Map<Object, Object> values { get; set; }
public ResponseDto(Boolean isSuccess, String msg){
this.isSuccess = isSuccess;
this.message = msg;
this.values = new Map<Object, Object>();
}
}