Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tarot
Last active September 22, 2015 08:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tarot/2ab5aea54969bde49d83 to your computer and use it in GitHub Desktop.
Save tarot/2ab5aea54969bde49d83 to your computer and use it in GitHub Desktop.
<aura:component implements="force:appHostable" controller="myfirstltngController">
<aura:attribute name="account" type="Account"/>
<aura:handler name="init" action="{!c.init}" value="{!this}"/>
{!v.account.Name}
<button onclick="{!c.save}">click</button>
</aura:component>
public with sharing class myfirstltngController {
@AuraEnabled
public static Account retrieveAccount() {
return [select Id, Name from Account limit 1];
}
@AuraEnabled
public static void saveAccount(Account account) {
system.debug(account);
upsert account;
}
}
({
init : function(component, event, helper) {
var action = component.get('c.retrieveAccount');
action.setCallback(this, function(data) {
component.set('v.account', data.getReturnValue());
});
$A.enqueueAction(action);
},
save: function(component, event, helper) {
component.set('v.account.Name', component.get('v.account.Name') + 'x')
var action = component.get('c.saveAccount');
action.setParams({account: component.get('v.account')});
$A.enqueueAction(action);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment