How to display a modal popup using aura components
When you build custom interfaces it is very common need to show a modal window or a popup window.
In this example we will go through how we can build a reusable modal window using lightning aura components.
If you are looking for a lightning web component (lwc) version of modal/popup component please check out
lwc modal.
Use cases
Display modal window or popup window in user interface
Show Yes/No confirmation modal popups
Steps to Implement
STEP 1 :- Create a component event with name Util_PressEvent.
This event is used to track click event on buttons that can be used to add listeners on modal component. Find the event file and metadata below,
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 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
STEP 2 :- Create an aura component with name Util_ModalWindow.
This component will contain all code needed to show and hide the modal popup,
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 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 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
STEP 3 :- You are all set to use the modal component. Let us use the modal component inside an aura component to show a modal popup.
Here we are using a parent aura component with name DemoAuraComponent to show modal popup.
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 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
Here we can add any content including other aura components between opening and closing tags of Util_ModalWindow.
All the content between the tags will be rendered as the body of the modal window.
https://theq.qcc.edu/ICS/Campus_Life/Campus_Groups/Nursing_112_2006/Group_Collaboration.jnz?portlet=%5BICS%5D_ForumPortlet&screen=PostView&screenType=change&id=b0448e2d-064e-4b95-9d27-4f9d14f7aa22
ReplyDelete