Reputation: 16364
I'm trying to change the width of a JQuery dialog after it has been initialized. Here is my initialization:
$(function() {
$("#dialogContainer").dialog({
title: 'Some title',
resizable: false,
bgiframe: true,
overlay: { opacity: 0.3, background: "white" },
position: [200, 200],
autoOpen: false,
height: 150,
width: 'auto'
modal: true,
buttons: {
'ok': function() {
$(this).dialog('close');
}
}
});
});
And this is what I am doing to change the width of it in some other function:
$("#dialogBox").dialog('option','width',700);
But this doesn't work. The width of the dialog is the width of the paragraph that's first displayed in it. Was I suppose to do anything else?
Here is the html for the dialog:
<div id = 'dialogContainer'>
<p id = 'message'></p>
</div>
Upvotes: 21
Views: 52111
Reputation: 1199
This works for me. The point is to resize after open it:
$('#dialogContainer').
dialog('open').
dialog('option', 'width', 'auto').
dialog('option', 'height', 'auto');
jQuery version in my case is 1.11:
> Query.fn.jquery
> "1.11.1"
Upvotes: 1
Reputation: 8199
Initialize the dialog with the width option specified: The width of the dialog is in pixels.
$( "#dialogBox" ).dialog({ width: 500 });
Get or set the width option, after initialization:
// getter
var width = $( "#dialogBox" ).dialog( "option", "width" );
// setter
$( "#dialogBox" ).dialog( "option", "width", 500 );
Source: http://api.jqueryui.com/dialog/
Upvotes: 7
Reputation: 2396
HERE IS SHORT SOLUTION, But remember it is only for predefined dialog.
$( "#dialog" ).dialog({minHeight: 300,minWidth:500});
Upvotes: 3
Reputation: 104168
Make sure that you are using ui.resizable.js and ui.resizable.css
Upvotes: 9