Cleaning Up Our Modal Dialog Code

Learn how to clean up our code using a dedicated region to manage the modal dialogs.

Now that we’re using modal dialogs in multiple places, it’s time to clean up our code by using a dedicated region to manage them. This region will be responsible for calling the dialog function to turn a view into a modal window and remove its DOM element when the dialog is closed, among other responsibilities.

Configuring existing dialogue regions

To achieve this, we’re simply going to make our existing dialog region automatically configure any view that it shows:

Get hands-on with 1200+ tech skills courses.