Skip to content

Instantly share code, notes, and snippets.

@jstvz
Forked from joebuschmann/force-showToast.js
Created May 13, 2017 02:14
Show Gist options
  • Save jstvz/21764e2565463fba265e635297b59c7d to your computer and use it in GitHub Desktop.
Save jstvz/21764e2565463fba265e635297b59c7d to your computer and use it in GitHub Desktop.
force:showToast event handler in a VF page
var postEventToOneApp = function(name, params, fallbackAction) {
if (SfdcApp && SfdcApp.projectOneNavigator && SfdcApp.projectOneNavigator.fireContainerEvent) {
// Not officially supported by Salesforce
SfdcApp.projectOneNavigator.fireContainerEvent(name, params);
} else if (fallbackAction) {
// Fallback if no Salesforce support of fireContainerEvent
fallbackAction();
}
};
$A.eventService.addHandler({
event: 'force:showToast',
handler: function(event) {
postEventToOneApp('force:showToast', event.$params$, function() {
alert(event.$params$.message);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment