Control.Dialog
Before proceeding you may want to read our getting started page.
What does this control do?
This control can be used to create custom modal windows. You can also use one of our predefined dialogs such as those we use to replace the ugly-by-default alert() or prompt() calls.
How to use
In order to use this control, paste this line of javascript right
at the beginning of your script tag:
You may then be able to invoke any of our predefined Dialog such as Dialog.alert(),
Dialog.prompt() or Dialog.question().
'This is an emergent message.',
{
'title': 'Dialog title'
}
);
Dialog.prompt(
'What is your name?',
{
'title': 'Dialog title',
'onOk': function(dialog) {
var yourName = this.value;
myNameIs(yourName);
dialog.close();
}
}
);
Dialog.question(
'Are you sure?',
{
'title': 'Dialog title',
'onYes': function(dialog) {
YesIAmSure();
dialog.close();
},
'onNo': function(dialog) {
noIAmNot();
dialog.close();
}
}
);
This is a classic dialog using common form elements expecting for user interaction:
// CONTENT
// You can use some text or an HTML element's reference
'Dialog inner content',
// OPTIONS
{
// WINDOW'S TITLE
'title': 'Dialog title',
// FORM BUTTONS
'buttons': {
// Cancel button
'buttonCancel': {
'caption': 'Cancel',
'onClick': function(dialog) {
dialog.close();
}
},
// OK button
'buttonOk': {
'caption': 'OK',
// This is the default button
'default': true,
'onClick': function(dialog) {
dialog.close();
}
}
// You can continue adding buttons if you want
}
}
);
// Centering the dialog
dialog.center();
dialog.show();
If you want to create a complete customized dialog, you can pass an HTML element's reference
to the contructor: