世间自有公道,付出总有回报,说到不如做到,要做就做好,步步高!

让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;
}
}
});
}
});

 

posted @ 2015-03-27 14:09  疯狂秀才  阅读(2088)  评论(0编辑  收藏  举报