扩展jquery ui对话框(添加更多选项)

我如何为jQuery对话框创建和添加新选项?
例如:我喜欢通过设置选项可以控制标题栏的显示显示关闭按钮.

脚本将是这样的:

$("#message").dialog({
  showTitle:false,//new option (hide Title bar)
  showCloseButton:true //new option (show close button)
  modal:true...        //other options
})

解决方法

这比我在评论中表达的要容易一些.
// store old method for later use
var oldcr = $.ui.dialog.prototype._create;
// add the two new options with default values
$.ui.dialog.prototype.options.showTitlebar = true;
$.ui.dialog.prototype.options.showClosebutton = true;
// override the original _create method
$.ui.dialog.prototype._create = function(){
    oldcr.apply(this,arguments);
    if (!this.options.showTitlebar) {
       this.uiDialogTitlebar.hide();
    }
    else if (!this.options.showClosebutton) {
       this.uiDialogTitlebar.find(".ui-dialog-titlebar-close").hide();
    }
};

// this is how you use it
$("<div />").dialog({
    showClosebutton: false
});
// or
$("<div />").dialog({
    showTitlebar: false
});

显然,如果标题栏被隐藏,关闭按钮也将被隐藏,因为它是标题栏的一部分.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...