Reputation: 4561
I wanted to use the jquery dialog box with a given size so I wrote :
$('#dialog').dialog("option", "width", 600 );
But I had an error :
Cannot call methods on dialog prior to initialization; attempted to call method 'option'
So I wrote :
$("#dialog").dialog();
$('#dialog').dialog("option", "width", 600 );
and it works..
Question 1 : it seems so strange to do like this that I wonder if it has to be done like that ?
Question 2 : if I have several options, let's say 'height', what is the syntax to add it ?
thank you
Upvotes: 0
Views: 67
Reputation: 5077
You can try something like this ..
$('#dialog').dialog({
modal: true,
width: 400,
height: 450});
Upvotes: 0
Reputation: 30993
You can set dialogwidth
and other options in its initialization.
Your attempt fails because you are trying to set a property before you instantiate the plugin on the element.
Like:
jQuery(document).ready(function() {
jQuery("#dialog").dialog({
modal: true,
width: 600
});
});
Demo: http://jsfiddle.net/IrvinDominin/SpFdS/
Upvotes: 2
Reputation: 1516
To answer both of your questions: You can pass in an object as the parameter:
$('#dialog').dialog({
'width':600,
'height':700
});
Hope this helps
Upvotes: 2