Utility class for generating different styles of message boxes. The alias Ext.Msg can also be used.
Note that the MessageBox is asynchronous. Unlike a regular JavaScript alert
(which will halt
browser execution), showing a MessageBox will not cause the code to stop. For this reason, if you have code
that should only run after some user feedback from the MessageBox, you must use a callback function
(see the function
parameter for show for more details).
Example usage:
// Basic alert:
Ext.Msg.alert('Status', 'Changes saved successfully.');
// Prompt for user data and process the result using a callback:
Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
if (btn == 'ok'){
// process text value and close...
}
});
// Show a dialog using config options:
Ext.Msg.show({
title:'Save Changes?',
msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
buttons: Ext.Msg.YESNOCANCEL,
fn: processResult,
animEl: 'elId',
icon: Ext.MessageBox.QUESTION
});
this
reference) in which the callback is executed. Defaults to the browser wnidow.this
reference) in which the callback is executed. Defaults to the browser wnidow.this
reference) in which the callback is executed. Defaults to the browser wnidow.Ext.MessageBox.INFO Ext.MessageBox.WARNING Ext.MessageBox.QUESTION Ext.MessageBox.ERROR
Progress and wait dialogs will ignore this option since they do not respond to user actions and can only be closed programmatically, so any required function should be called by the same code after it closes the dialog. Parameters passed:
Ext.Msg.show({
title: 'Address',
msg: 'Please enter your address:',
width: 300,
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
fn: saveAddress,
animEl: 'addAddressBtn',
icon: Ext.MessageBox.INFO
});