Dialogs are commonly used to ask the user to either confirm or supply information client side, without requiring the user to perform a post back. Sitemagic CMS ships with the SMMessageDialog class
which supports the following types of dialogs:
- Message dialog (alert box with information)
- Confirm dialog (alert box with information and OK/Cancel buttons)
- Input dialog (input box with information and OK/Cancel buttons)
- Password dialog (input box with password field that hides the value entered)
// Using the message dialog
SMMessageDialog.ShowMessageDialog("Please update your bookmark");
// Using the confirm dialog
if (SMMessageDialog.ShowConfirmDialog("Delete selected item?") === true)
// User confirmed action (clicked OK) - do something here..
// Using the input dialog
var name = SMMessageDialog.ShowInputDialog("What is your name?", "Enter name here..");
if (name !== null) // name variable will be null if user canceled or closed the input dialog
// User entered a value - do something here..
// Using the password dialog
// This function executes when the password is either specified or the dialog is closed.
if (pass !== null) // Password specified
// Do something with the password here..
// User canceled the password dialog
SMMessageDialog.ShowMessageDialog("You must enter your password to log in!");
}, "Enter password", "Please enter the password received by e-mail");