Implementing the Modal Functionality
Discover how to implement modal window functionality in Marionette.js by creating dedicated regions for modals, displaying edit forms upon user interaction, and using event-driven methods to dynamically adjust modal titles. This lesson helps you enhance user experience with efficient and reusable modal views for contact editing.
We'll cover the following...
So far, we have implemented a modal view but haven’t added any functionality to it.
DOM element
If we want to display modal windows, we’ll need a region to show them. Let’s add a DOM element for our modal dialogs in the following code in line 7:
We also need Marionette to configure this new DOM element as a region within our application:
Display on click
Let’s display our edit form in a modal window when the user clicks the edit link in our List view:
We reuse our Edit.Contact view from the Edit submodule and display it within a modal. This is achieved by calling jQuery UI’s dialog method on the view’s element. Take a look at how this behavior is organized: ...