Modal dialogs
After the overuse of modal dialogs in Windows, and alert boxes in early browser applications, modal dialogs have left a bad taste with some developers. However, when used appropriately, they are simple and powerful tools. Durandal's modal dialog implementation makes collecting user input from modals very easy, by making dialogs return promises that resolve when they close. Modal dialogs in Durandal come in two types, namely, message boxes and custom dialogs.
Message boxes
For simple cases such as displaying a notification or collecting a single piece of user input, Durandal provides a modal dialog on app.showMessage
, which takes the following parameters:
Message (string)
: This contains the main contents of the message box.Title (string, optional)
: This contains the title of the message box; the default title isapp.title
.Buttons (array, optional)
: This is an array of buttons to show; the default is['Ok']
. The first button in the array will be the default action of the dialog...