简体   繁体   English

删除jQuery UI对话框小部件上的关闭按钮的最佳方法是什么?

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

What's the best way to remove the close button on the jQuery UI dialog box? 删除jQuery UI对话框上的关闭按钮的最佳方法是什么?

I do not wish people to be able to close the dialog box. 我不希望人们能够关闭对话框。

I'm covering it on the code angle by handling: 我通过处理代码角度覆盖它:

closeOnEscape: false,
beforeclose: function (event, ui) { return false; }

I'm trying not to need to write script to grap the class / id of the close button and then hide it manually. 我试图不需要编写脚本来抓取关闭按钮的类/ id,然后手动隐藏它。 And I'd rather not change the CSS manually either, as the dialog box may have situations where it needs the close button. 而且我不想手动更改CSS,因为对话框可能有需要关闭按钮的情况。

I'd prefer to do it the dialog config somehow, but either I can't figure out how to do it or the dialog box doesn't allow for it at all. 我更喜欢以某种方式对话框配置,但要么我不知道如何做,或者对话框根本不允许它。

Any suggestions on how to configure the dialog box? 有关如何配置对话框的任何建议?

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. 添加类最终成为一个非常优雅的方法,因为我将对话框“分类”为无法关闭的对话框。

I found another solution, works for me: 我找到了另一个解决方案,对我有用:

$("#divID").dialog({
   closeOnEscape: false,
   open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM