The framework provides a set of standard dialogs for displaying simple messages to the user, or asking yes/no questions.
These are all fundamentally the same dialog, but with different cosmetic styling and default buttons. For example, you can change the error dialog so that it has yes/no buttons, and you can change the confirmation dialog so that it only has a single "okay" button.
The functions provided by the framework in this area are as follows:
| Function | Description |
| Ask() | Asks the user a question |
| ErrorMessage() | Displays a message styled as an error |
| SuccessMessage() | Displays a message styled as success |
| AlertMessage() | Displays a message styled as an alert/notification |
| InfoMessage() | Displays a message styled as information |
Each of these functions takes two parameters: a block of settings, and a callback function which receives the dialog result. Note that the callback function gets called multiple times. There is an initial call which provides the dialog ID, allowing it to be destroyed by the caller, and a final call containing a
Framework.Ask("Are you sure?", function(Msg) {
if (Msg.result) {
// Final result from dialog
} else {
// Initial callback providing dialog ID
}
});
The settings can either be a simple string, as in the above example, or an object with properties. For example:
Framework.Ask({
title: "Really?",
text: "Are you sure you want to do this?",
buttons: [
{text: "Yes, definitely", value: "Yup", className: "btn-red"},
{text: "On second thoughts…", value: "No"}
]
}, function (Msg) {
if (Msg.result && Msg.result.msg == "Yup") {
// User clicked button with value Yup
} else {
// Initial callback providing dialog ID
}
});