Created
February 25, 2015 20:24
-
-
Save mshanemc/127dfeed535af8763a71 to your computer and use it in GitHub Desktop.
Lightning Component Navigation with Fallback
This file contains 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
({ | |
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