Created
October 30, 2017 18:52
-
-
Save kbshl/45b786b38a958402dfeace1f5f1bfa56 to your computer and use it in GitHub Desktop.
JS for Lightning Component in Visualforce Page
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
(function constructor() { | |
let recordId = '{!Assignment__c.Id}'; | |
let userContext = '{!$User.UITheme}'; | |
$Lightning.use('c:HotelCheckInApp', function _createHotelCheckInComponent() { | |
$.Lightning.createComponent('c:HotelCheckIn', { recordId: recordId }, 'lightningComponent', function _handleCreatedComponent(component) { | |
console.info('HotelCheckIn Lightning Component created'); | |
}); | |
}); | |
}()); | |
$Lightning.use("c:SimilarPropertiesApp", function () { | |
$Lightning.createComponent("c:SimilarProperties", | |
{ recordId: recordId }, | |
"lightningComponent", | |
function (cmp) { | |
$A.eventService.addHandler({ | |
event: 'force:navigateToSObject', | |
handler: function (event) { | |
if (myUserContext == 'Theme4t' || myUserContext == 'Theme4d') { | |
// The Visualforce page is in S1 or Lightning Experience | |
sforce.one.navigateToSObject(event.getParams().recordId); | |
} else if (myUserContext == 'Theme3') { | |
// The Visualforce page is running in Classic | |
window.parent.location = '/' + event.getParams().recordId; | |
} else { | |
console.log("Unsupported theme"); | |
} | |
} | |
}); | |
} | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment