如何删除jQueryUI创建的对话框上的关闭按钮(右上角的X)?
当前回答
由于我发现我在应用程序的几个地方都在做这件事,所以我把它包装在一个插件中:
(function ($) {
$.fn.dialogNoClose = function () {
return this.each(function () {
// hide the close button and prevent ESC key from closing
$(this).closest(".ui-dialog").find(".ui-dialog-titlebar-close").hide();
$(this).dialog("option", "closeOnEscape", false);
});
};
})(jQuery)
用法示例:
$("#dialog").dialog({ /* lots of options */ }).dialogNoClose();
其他回答
以上这些都不起作用。真正有效的解决方案是:
$(function(){
//this is your dialog:
$('#mydiv').dialog({
// Step 1. Add an extra class to our dialog to address the dialog directly. Make sure that this class is not used anywhere else:
dialogClass: 'my-extra-class'
})
// Step 2. Hide the close 'X' button on the dialog that you marked with your extra class
$('.my-extra-class').find('.ui-dialog-titlebar-close').css('display','none');
// Step 3. Enjoy your dialog without the 'X' link
})
请检查它是否适合您。
Dialog小部件添加的关闭按钮具有类“ui Dialog titlebar close”,因此在首次调用.Dialog()后,您可以使用如下语句再次删除关闭按钮:它起作用了。。
$( 'a.ui-dialog-titlebar-close' ).remove();
$(".ui-button-icon-only").hide();
使用这个纯CSS行怎么样?我发现对于具有给定Id的对话框,这是最干净的解决方案:
.ui-dialog[aria-describedby="IdValueOfDialog"] .ui-dialog-titlebar-close { display: none; }
我捕捉对话框的关闭事件。然后,此代码删除<div>(#dhx_combo_list):
open: function(event, ui) {
//hide close button.
$(this).parent().children().children('.ui-dialog-titlebar-close').click(function(){
$("#dhx_combo_list").remove();
});
},
推荐文章
- 使伸缩项目正确浮动
- 可以在setInterval()内部调用clearInterval()吗?
- 无法读取未定义的属性“msie”- jQuery工具
- 如何取消最大高度?
- 形式内联内的形式水平在twitter bootstrap?
- 自定义元素在HTML5中有效吗?
- 如何选择在最后一个子元素之前的元素?
- 如何触发自动填充在谷歌Chrome?
- jQuery:执行同步AJAX请求
- CSS变换,锯齿边缘在铬
- 创建圈div比使用图像更容易的方法?
- 强迫孩子服从父母的弯曲边界在CSS
- jQuery表格排序
- 如何禁用文本选择使用jQuery?
- 为什么Chrome浏览器不正确地确定页面是在不同的语言,并提供翻译?