封装 jquery ui 的dialog
(function ($) { var default1={ titleText:"提示对话框", submitBtnText:"确 认", cancelBtnText:"取 消", width:"200", height:"200", openCall:function(){}, closeCall:function(){}, submitCall:function(){}, position:["middle","center"], jq:"" ,//jquery对象 $("#alert") jqMsg:"", //存放提示文字信息的jquery对象 $("#alertMsg") msg:""//提示内容 }; $.alertNoButton=function(option){ var opt= $.extend(default1,option); opt.jq.dialog("destroy" ); opt.jq.dialog({ modal:true, title:opt.titleText, width:opt.width, height:opt.height, position:opt.position, resizable:false, draggable:false, open:function(even,ui){ if ($.isFunction(opt.openCall)) { opt.openCall(); } } }); }; $.alertDialogs=function(option){ var opt= $.extend(default1,option); opt.jq.dialog("destroy" ); opt.jq.dialog({ modal:true, title:opt.titleText, width:opt.width, height:opt.height, position:opt.position, resizable:false, draggable:false, buttons: [ { text: opt.submitBtnText, click: function() { if ($.isFunction(opt.submitCall)) { opt.submitCall(); } } }, { text:opt.cancelBtnText, click: function() { opt.jq.dialog("close"); } } ], open:function(even,ui){ $(".ui-dialog-buttonset button").eq(1).css({"margin-left":"40px"}); if ($.isFunction(opt.openCall)) { opt.openCall(); } }, close:function(){ if ($.isFunction(opt.closeCall)) { opt.closeCall(); } } }); }; $.alertDialog = function (option){ var opt= $.extend(default1,option); opt.jq.dialog( "destroy" ); opt.jq.dialog({ modal:true, title:opt.titleText, width:opt.width, height:opt.height, position:opt.position, resizable:false, draggable:false, buttons: [ { text: opt.submitBtnText, click: function() { if ($.isFunction(opt.submitCall)) { opt.submitCall(); } } } ], open:function(even,ui){ if(opt.jqMsg){ opt.jqMsg.text(opt.msg); } if ($.isFunction(opt.openCall)) { opt.openCall(); } }, close:function(even,ui){ if ($.isFunction(opt.closeCall)) { opt.closeCall(); } } }); }; $.confirmDialog = function (option) { var opt= $.extend(default1,option); opt.jq.dialog("destroy"); opt.jq.dialog({ resizable:false, draggable:false, title:opt.titleText, position:opt.position, width:opt.width, height:opt.height, modal:true, buttons: [ { text: opt.submitBtnText, click: function() { if ($.isFunction(opt.submitCall)) { opt.submitCall(); } } }, { text:opt.cancelBtnText, click: function() { opt.jq.dialog("close"); } } ], open:function(){ opt.jqMsg.text(opt.msg); } }); } })(jQuery);
调用:
$.alertDialog({titleText:"错误信息提示",height:"150",width:"300",jq:$("#alert"),jqMsg:$("#alertMsg") ,msg:"您不同意万事达服务条款,不能预定", submitCall:function(){ $("#alert").dialog("close"); } });
相关推荐
apowerfulman 2020-03-03
hustlei 2011-03-03
Mexican 2011-08-31
larrywangsun 2011-08-09
TTHHVV 2011-09-28
87384559 2014-11-11
xuewenke 2015-11-04
火星的你 2015-10-25
王磊的程序员之路 2019-06-19
十一郎的IT 2013-10-29
攻城师 2019-06-28
89453862 2016-05-13
SinhaengHhjian 2015-11-04
sunnylinner 2014-11-11