Last active
March 12, 2018 03:34
-
-
Save ketan-benegal/575959fd45a5e5e170e430e749e1aab2 to your computer and use it in GitHub Desktop.
Lightning Toast
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
<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 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
.THIS { | |
} | |
.THIS .warning_cls { | |
background : #FFB75F !important; | |
} | |
.THIS .success_cls { | |
background : #04842D !important; | |
} |
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
({ | |
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