Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

with jquery UI dialog, is there anyway to have a max height and use 'auto' if its smaller

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?

like image 456
leora Avatar asked Apr 14 '11 10:04

leora


People also ask

How to set max height of div using jQuery?

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).

How make jQuery ui dialog responsive?

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.

What is jQuery ui 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.


3 Answers

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.

like image 79
mekwall Avatar answered Nov 27 '22 11:11

mekwall


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.

like image 37
clime Avatar answered Nov 27 '22 12:11

clime


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>
like image 35
pivotal developer Avatar answered Nov 27 '22 11:11

pivotal developer