Last active
January 16, 2021 10:18
-
-
Save pozil/4a3fedf30836379dd6fc7c8668046f18 to your computer and use it in GitHub Desktop.
Lightning - Displaying a system toast with a few lines of code
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="force:appHostable,flexipage:availableForAllPageTypes" access="global"> | |
<div class="slds-m-around--xx-large slds-text-align--center"> | |
<lightning:button label="Fire toast event" onclick="{! c.fireToastEvent }"/> | |
</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
({ | |
fireToastEvent : function(component, event, helper) { | |
var toastEvent = $A.get("e.force:showToast"); | |
toastEvent.setParams({ | |
"title": "Success!", | |
"message": "It works!", | |
"type": "success" | |
}); | |
toastEvent.fire(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes it's a component that you can edit. I just need to add a method on the code that will show notification to users on click of a button.