用来生成不同样式的消息框的实用类。还可以使用它的别名Ext.Msg。Utility class for generating different styles of message boxes. The alias Ext.Msg can also be used.
需要注意的是 MessageBox 对象是异步的。不同于 JavaScript中原生的alert(它会暂停浏览器的执行),显示 MessageBox 不会中断代码的运行。由于这个原因,如果你的代码需要在用户对 MessageBox 做出反馈之后执行,则必须用到回调函数(详情可见show方法中的function参数)。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
});
类Ext.MessageBox
猜你喜欢
转载自jenniferamanda.iteye.com/blog/1699902
今日推荐
周排行