Book Image

Mastering KnockoutJS

By : Timothy Moran
Book Image

Mastering KnockoutJS

By: Timothy Moran

Overview of this book

Table of Contents (16 chapters)
Mastering KnockoutJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 is app.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...