Is it possible to open a jQuery UI Dialog without a title bar?
This is the easiest way to do it and it will only remove the titlebar in that one specific dialog;
$('.dialog_selector').find('.ui-dialog-titlebar').hide();
go to your jquery-ui.js (in my case jquery-ui-1.10.3.custom.js) and search for this._createTitlebar(); and comment it.
now anyone of yours dialog will appear with headers. If you want to customize the header just go to _createTitlebar(); and edit the code inside.
by
You can use jquery to hide titlebar after using dialogClass when initializing the dialog.
during init :
$('.selector').dialog({
dialogClass: 'yourclassname'
});
$('.yourclassname div.ui-dialog-titlebar').hide();
By using this method, you don't need to change your css file, and this is dynamic too.
I like overriding jQuery widgets.
(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);
So you can now setup if you want to show title bar or not
$('#mydialog').dialog({
headerVisible: false // or true
});
This next form fixed me the problem.
$('#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>
I find it more efficient, and more readable, to use the open event, and hide the title bar from there. I don't like using page-global class name searches.
open: function() { $(this).closest(".ui-dialog").find(".ui-dialog-titlebar:first").hide(); }
Simple.