@author YHC
覆盖默认值 $.messager.defaults.
messager提供不同类型的消息框,包含confirm, prompt, progress等等.所有的消息框都是异步的,用户可以使用messager回调函数做交互.
相关依赖
- window
- linkbutton
- progressbar
使用
$.messager.alert('Warning','The warning message');
$.messager.confirm('Confirm','Are you sure you want to delete record?',function(r){
if (r){
alert('ok');
}
});
属性
Name | Type | Description | Default |
---|---|---|---|
ok | string | Ok 按钮显示文本. | Ok |
cancel | string | Cancel 按钮显示文本. | Cancel |
Methods
Name | Parameters | Description |
---|---|---|
$.messager.show | options | 显示一个消息窗体在屏幕的右下. options参数是一个配置对象: showType:定义消息窗体如何显示 可用值有: null,slide,fade,show. 默认值是slide. showSpeed: 定义消息窗体最终显示的毫秒数. 默认值是 600. width: 定义消息窗体宽度.默认值是 250. height: 定义消息窗体高度. 默认值是100. msg: 显示的消息文本. title: 标题文本显示到panel的头部的. timeout: 如果定义为 0,消息窗体将不会关闭除非用户关闭.定义为不是0,消息窗体将在时间超时后自动关闭. 示例代码: $.messager.show({ title:'My Title', msg:'Message will be closed after 5 seconds.', timeout:5000, showType:'slide' }); |
$.messager.alert | title, msg, icon, fn | 显示一个alter窗体.参数: title: 标题文本,显示在panel的头部的. msg: 显示的消息文本. icon:显示icon图片,可用值有: error,question,info,warning. fn: 窗体关闭的时候触发的回调函数. 示例代码: $.messager.alert('My Title','Here is a info message!','info'); |
$.messager.confirm | title, msg, fn | 显示一个确认消息窗体有一个OK和一个Cancel按钮,参数: title:标题文本显示在panel的头部的. msg:显示的消息文本. fn(b): 回调函数,当用户点击OK按钮传入true值到函数,其他则传入false. 示例代码: $.messager.confirm('Confirm', 'Are you sure to exit this system?', function(r){ if (r){ // exit action; } }); |
$.messager.prompt | title, msg, fn | 显示一个消息窗体,一个OK和一个Cancel按钮,提示用户输入一些文本,参数: title: 显示到panel头部的标题文本. msg: 显示的消息文本. fn(val): 回调函数,value参数是用户输入的值. 示例代码: $.messager.prompt('Prompt', 'Please enter your name:', function(r){ if (r){ alert('Your name is:' + r); } }); |
$.messager.progress | options or method | 显示一个进度消息窗体. 选项定义如下: title: 显示到panel头部的标题文本,默认值''. msg: 消息框的body文本,默认值''. text: 这个文本显示到进度条上, 默认未定义. interval: 每个进度更新的毫秒值长度,默认值 300. 方法定义如下: bar:得到 progressbar 对象. close: 关闭进度条窗体. 示例代码显示进度消息框.$.messager.progress();现在关闭进度消息框. $.messager.progress('close'); |