Skip to content

Instantly share code, notes, and snippets.

@mshanemc
Created February 25, 2015 20:24
Show Gist options
  • Save mshanemc/127dfeed535af8763a71 to your computer and use it in GitHub Desktop.
Save mshanemc/127dfeed535af8763a71 to your computer and use it in GitHub Desktop.
Lightning Component Navigation with Fallback
({
update: function(component, evt, helper) {
var expense = component.get("v.expense");
var updateEvent = $A.get("e.c:updateExpenseItem");
updateEvent.setParams({ "expense": expense }).fire();
},
gotoRecord: function(component, evt, helper) {
console.log("onclick");
var sObjectEvent = $A.get("e.force:navigateToSObject");
console.log(sObjectEvent===null);
if (sObjectEvent){ //strategy: it's in SF1
sObjectEvent.setParams({
"recordId": component.get("v.expense.Id")
});
sObjectEvent.fire();
} else { //fallback for when we're not in SF1
window.location.href = "/" + component.get("v.expense.Id");
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment