Skip to content

Instantly share code, notes, and snippets.

@ketan-benegal
Last active March 12, 2018 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ketan-benegal/575959fd45a5e5e170e430e749e1aab2 to your computer and use it in GitHub Desktop.
Save ketan-benegal/575959fd45a5e5e170e430e749e1aab2 to your computer and use it in GitHub Desktop.
Lightning Toast
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,flexipage:availableForAllPageTypes" access="global" >
<div>
<lightning:button label="Information" variant="brand" onclick="{!c.showInfoToast}" />
<lightning:button label="Error" variant="destructive" onclick="{!c.showErrorToast}" />
<lightning:button label="Warning" variant="inverse" onclick="{!c.showWarningToast}" class = "warning_cls" />
<lightning:button label="Success" variant="inverse" onclick="{!c.showSuccessToast}" class = "success_cls" />
</div>
</aura:component>
.THIS {
}
.THIS .warning_cls {
background : #FFB75F !important;
}
.THIS .success_cls {
background : #04842D !important;
}
({
showInfoToast : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : 'Info Toast Message',
message: 'This is Info Toast...!!!',
duration:' 4000',
key: 'info_alt',
type: 'info',
mode: 'dismissible'
});
toastEvent.fire();
},
showSuccessToast : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : 'Success Toast Message',
message: 'This is Success Toast...!!!',
duration:' 4000',
key: 'info_alt',
type: 'success',
mode: 'pester'
});
toastEvent.fire();
},
showErrorToast : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : 'Error Toast Message',
message:'This is Error Toast...!!!',
messageTemplate: 'Mode is pester ,duration is 4sec and Message is overrriden',
duration:' 4000',
key: 'info_alt',
type: 'error',
mode: 'pester'
});
toastEvent.fire();
},
showWarningToast : function(component, event, helper) {
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : 'Warning Toast Message',
message: 'This is Warning Toast...!!!',
messageTemplate: 'Mode is sticky ,duration is 4sec and Message is overrriden because messageTemplateData is {1}',
messageTemplateData: ['Salesforce Lightning', {
url: 'http://www.thecloudfountain.com/category/blog/',
label: 'Click Here',
}],
duration:' 4000',
key: 'info_alt',
type: 'warning',
mode: 'sticky'
});
toastEvent.fire();
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment