有没有可能打开一个jQuery UI对话框没有标题栏?
当前回答
我想出了一个动态删除标题栏的解决方案。
$("#example").dialog(dialogOpts);
// remove the title bar
$(".ui-dialog-titlebar").hide();
这将在对话框渲染后删除所有带有'ui-dialog-titlebar'类的元素。
其他回答
我认为最好的解决方案是使用选项dialogClass。
jquery UI文档的一个摘录:
在init: $('.selector')期间。dialog({dialogClass: 'noTitleStuff'});
或者在init之后。:
$('.selector').dialog('option', 'dialogClass', 'noTitleStuff');
所以我创建了一些对话框选项dialogClass='noTitleStuff'和css像这样:
.noTitleStuff .ui-dialog-titlebar {display:none}
太简单了!!但是我花了1天的时间来思考为什么我之前的id->类钻井方法不起作用。事实上,当你调用.dialog()方法时,你转换的div成为另一个div(真正的对话框div)的孩子,可能是标题栏div的“兄弟”,所以很难尝试从前者开始寻找后者。
我想出了一个动态删除标题栏的解决方案。
$("#example").dialog(dialogOpts);
// remove the title bar
$(".ui-dialog-titlebar").hide();
这将在对话框渲染后删除所有带有'ui-dialog-titlebar'类的元素。
试着用
$("#mydialog").closest(".ui-dialog-titlebar").hide();
这将隐藏所有对话框的标题
$(".ui-dialog-titlebar").hide();
转到你的jquery-ui.js(在我的情况下是jquery-ui-1.10.3.custom.js)并搜索this._createTitlebar();并对其进行注释。
现在你的任何一个对话框都会显示标题。如果你想自定义标题,只需去_createTitlebar();并编辑其中的代码。
by
如果你有多个对话框,你可以使用这个:
$("#the_dialog").dialog({
open: function(event, ui) {
//hide titlebar.
$(this).parent().children('.ui-dialog-titlebar').hide();
}
});
推荐文章
- src和dist文件夹的作用是什么?
- jQuery UI对话框-缺少关闭图标
- jQuery。由于转义了JSON中的单引号,parseJSON抛出“无效JSON”错误
- 如何使用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数据?