jquery UI dialog: how to initialize without a title bar?

前端 未结 23 1707
春和景丽
春和景丽 2020-11-29 15:03

Is it possible to open a jQuery UI Dialog without a title bar?

23条回答
  •  一整个雨季
    2020-11-29 15:41

    I like overriding jQuery widgets.

    (function ($) {
        $.widget("sauti.dialog", $.ui.dialog, {
            options: {
                headerVisible: false
            },
            _create: function () {
                // ready to generate button
                this._super("_create"); // for 18 would be $.Widget.prototype._create.call(this);
                // decide if header is visible
                if(this.options.headerVisible == false)
                    this.uiDialogTitlebar.hide();
            },
            _setOption: function (key, value) {
                this._super(key, value); // for 1.8 would be $.Widget.prototype._setOption.apply( this, arguments );
                if (key === "headerVisible") {
                    if (key == false)
                        this.uiDialogTitlebar.hide();
                    else
                        this.uiDialogTitlebar.show();
                    return;
                }
            }
        });
    })(jQuery);
    

    So you can now setup if you want to show title bar or not

       $('#mydialog').dialog({
          headerVisible: false // or true
    });
    

提交回复
热议问题