I want a dialog to have a max height setting but, if the content is smaller, then to shrink down to do what height = 'auto'
does. Is this possible in JQuery UI dialog?
jQuery: Calculate max height and apply to all element using jQuery. Here equalheight is parent class to find intro class and set equal height to all. maxHeight = $(this).
Below is how I achieved a responsive jQuery UI Dialog. To do this, I added a new option to the config - fluid: true , which says to make the dialog responsive. I then catch the resize and dialog open events, to change the max-width of the dialog on the fly, and reposition the dialog.
The jQuery UI dialog method is used to create a basic dialog window which is positioned into the viewport and protected from page content. It has a title bar and a content area, and can be moved, resized and closed with the 'x' icon by default.
You can achieve this by doing the following:
HTML
<div id="dialog" title="Dialog Title"> Dialog content </div>
JavaScript
$('#dialog').dialog({ resizable: false, minHeight: 0, create: function() { $(this).css("maxHeight", 400); } });
Check out test case on jsFiddle.
I use this:
$('#dialog').dialog({ maxHeight: $(window).height(), open: function() { $(this).dialog('option', 'maxHeight', $(window).height()); } });
Resetting maxHeight in "open" is useful when window has changed size.
You can do it like this:
$('#testing').resizable("enable");
$('#testing').dialog({ maxHeight: 400 });
<div id="testing" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With