有没有可能打开一个jQuery UI对话框没有标题栏?
当前回答
当隐藏Dialog标题栏时,我发现,即使display为none,屏幕阅读器仍然会读取它。如果您已经添加了自己的标题栏,它将同时显示这两种内容,从而造成混淆。
我所做的是使用$(selector).remove()从DOM中删除它。现在屏幕阅读器(和其他人)将看不到它,因为它已经不存在了。
其他回答
我喜欢重写jQuery小部件。
(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);
你现在可以设置是否显示标题栏
$('#mydialog').dialog({
headerVisible: false // or true
});
我相信你可以用CSS隐藏它:
.ui-dialog-titlebar {
display: none;
}
或者,你可以使用dialogClass选项将其应用于特定的对话框:
$( "#createUserDialog" ).dialog({
dialogClass: "no-titlebar"
});
.no-titlebar .ui-dialog-titlebar {
display: none;
}
看看“主题化”对话。上面的建议使用了dialogClass选项,该选项似乎正在被一种新的方法取代。
我在我的项目中使用这个
$("#myDialog").dialog(dialogOpts);
// remove the title bar
$("#myDialog").siblings('div.ui-dialog-titlebar').remove();
// one liner
$("#myDialog").dialog(dialogOpts).siblings('.ui-dialog-titlebar').remove();
我想出了一个动态删除标题栏的解决方案。
$("#example").dialog(dialogOpts);
// remove the title bar
$(".ui-dialog-titlebar").hide();
这将在对话框渲染后删除所有带有'ui-dialog-titlebar'类的元素。
试试这个
$("#ui-dialog-title-divid").parent().hide();
将divid替换为相应的id
推荐文章
- 如何使用jQuery检测页面的滚动位置
- 如何在JSON中使用杰克逊更改字段名
- 在JavaScript中根据键值查找和删除数组中的对象
- 防止在ASP中缓存。NET MVC中使用属性的特定操作
- jQuery: keyPress退格键不火?
- XMLHttpRequest Origin null不允许Access-Control-Allow-Origin for file:/// to file:///(无服务器)
- 重置setTimeout
- jQuery有不聚焦的方法吗?
- jQuery -替换字符串中某个字符的所有实例
- Ng-repeat结束事件
- 模糊vs聚焦-有什么真正的区别吗?
- 如何用jQuery / JavaScript解析JSON数据?
- jQuery在请求体中发布有效的json
- jQuery中的live()转换为on()
- jQuery等价于JavaScript的addEventListener方法