Last active
August 29, 2015 14:24
-
-
Save msrivastav13/c5cf253e24cf3eef5217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Event Definations in event file--> | |
<aura:event type="APPLICATION"> | |
<aura:attribute name="saccount" type="Account"/> <!Note Attribute carries Pay load--> | |
</aura:event> | |
<!--Publish events from edit component--> | |
<aura:registerEvent name="saveAccount" type="c:saverowEvent" /> | |
<ui:button label="Submit" press="{!c.updateAccount}" class="btn btn-default btn-lg btn-block"/> | |
//Javascript that fires when save button is clicked.This is on controller file | |
updateAccount: function(component, event, helper) { | |
var saveEvent = $A.get("e.c:saverowEvent"); | |
var saveacc = component.get("v.acttoedit"); | |
saveEvent.setParams({ "actsave": saveacc}); | |
if(saveacc.Id==null){ | |
saveEvent.setParams({ "isupdate": false}); | |
}else{ | |
saveEvent.setParams({ "isupdate": true}); | |
} | |
saveEvent.fire(); | |
} | |
/* Part of code in main component that handles this event *\ | |
<aura:handler event="c:saverowEvent" action="{!c.detailnavigate}"/> | |
//Script that gets payload back from Events | |
detailnavigate:function(component,event,helper) { | |
helper.upsertAcc(component,event); | |
}, | |
//Script on helper file that captures payload from the Event and makes a server call and updates client back | |
upsertAcc: function(component,event) { | |
var action = component.get("c.saveAccount"); | |
var saveaccount = event.getParam("actsave"); | |
console.log(saveaccount); | |
action.setParams({ | |
"acc": saveaccount | |
}); | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
}, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment