让easyui 的alert 消息框中的确定按钮支持空格键
var _messager = $.extend({},$.messager);
$.extend($.messager,{
alert:function(title, msg, icon, fn){
var win = _messager.alert.call(this,title,msg,icon,fn);
win.on('keyup',function(e){
if(e.which ==32){
win.window('close');
if (fn){
fn();
return false;
}
}
});
},
confirm: function(title,msg,fn){
var win = _messager.confirm.call(this,title,msg,fn);
win.on('keyup',function(e){
if(e.which ==32 || e.which ==13){
win.window('close');
if (fn){
fn(true);
return false;
}
}
if(e.which == 27) { // esc
win.window('close');
if(fn){
fn(false);return false;
}
}
});
},
prompt:function(title,msg,fn){
var win = _messager.prompt.call(this,title,msg,fn);
win.on('keyup',function(e){
if(e.which ==13){
win.window('close');
if (fn){
fn($('.messager-input', win).val());
return false;
}
}
if(e.which == 27) { // esc
win.window('close');
if(fn){
fn();return false;
}
}
});
}
});