有没有可能打开一个jQuery UI对话框没有标题栏?
当前回答
我认为最简洁的方法是创建一个新的myDialog小部件,由对话框小部件减去标题条形码组成。删除标题条形码看起来很简单。
https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.dialog.js
其他回答
下一种形式解决了我的问题。
$('#btnShow').click(function() { $("#basicModal").dialog({ modal: true, height: 300, width: 400, create: function() { $(".ui-dialog").find(".ui-dialog-titlebar").css({ 'background-image': 'none', 'background-color': 'white', 'border': 'none' }); } }); }); #basicModal { display: none; } <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css" /> <div id="basicModal"> Here your HTML content </div> <button id="btnShow">Show me!</button>
我喜欢重写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
});
转到你的jquery-ui.js(在我的情况下是jquery-ui-1.10.3.custom.js)并搜索this._createTitlebar();并对其进行注释。
现在你的任何一个对话框都会显示标题。如果你想自定义标题,只需去_createTitlebar();并编辑其中的代码。
by
我相信你可以用CSS隐藏它:
.ui-dialog-titlebar {
display: none;
}
或者,你可以使用dialogClass选项将其应用于特定的对话框:
$( "#createUserDialog" ).dialog({
dialogClass: "no-titlebar"
});
.no-titlebar .ui-dialog-titlebar {
display: none;
}
看看“主题化”对话。上面的建议使用了dialogClass选项,该选项似乎正在被一种新的方法取代。
试着用
$("#mydialog").closest(".ui-dialog-titlebar").hide();
这将隐藏所有对话框的标题
$(".ui-dialog-titlebar").hide();
推荐文章
- 使用jQuery以像素为整数填充或边距值
- 检查是否选择了jQuery选项,如果没有选择默认值
- 将Dropzone.js与其他字段集成到现有的HTML表单中
- 使用jQuery滚动到一个div
- 在JS/jQuery中触发按键/按键/按键事件?
- 如何每5秒重新加载页面?
- getJSON调用中的错误处理
- 如何用jquery或javascript排序对象数组
- 使用jQuery切换输入禁用属性
- 如何知道一个字符串开始/结束在jQuery特定的字符串?
- Twitter Bootstrap vs jQuery UI?
- 如何绑定“触摸启动”和“点击”事件,但不回应两者?
- 如何使用jQuery从URL中获得锚?
- console.log(result)输出[object对象]。我如何得到result。name?
- 在jQuery中检测输入[type=text]的值变化