Best way to remove the close button on jQuery UI dialog box widget?

后端 未结 2 1591
醉梦人生
醉梦人生 2021-02-04 01:23

What\'s the best way to remove the close button on the jQuery UI dialog box?

I do not wish people to be able to close the dialog box.

I\'m covering it on the cod

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-04 01:39

    I found this to be a good solution

    $("#myDialogID").dialog({
        closeOnEscape: false,
        beforeClose: function (event, ui) { return false; },
        dialogClass: "noclose"
    });
    

    Not altering the existing styles, instead adding a new bit:

    .noclose .ui-dialog-titlebar-close
    {
        display:none;
    }
    

    Adding the class ended up being quite an elegant method, as i'm "classing" the dialog as one that cannot be closed.

提交回复
热议问题