Joseph Michael Pesch
VP Programming

jQuery UI Dialog Height Issue - Height Collapses when Re-Opening a Dialog

by 17. February 2014 21:36

I experienced an issue with jQuery dialog box if I opened the same dialog a second time the height would be collapsed so the content was not showing.  It seems the issue is related to allowing the jQuery dialog to open on creation (i.e. autoOpen = true, which is the default so if you leave the autoOpen parameter off the dialog creation it will autoOpen by default).  Instead, you should create the dialog (with autoOpen = false) and then explicitly open the dialog (e.g. $dlg.dialog('open'), see sample code below). 

/* Problem code */
$("#objectid").dialog({
  height: 680,
  width: 800,
  modal: true,
  resizable: false
});

/* Solution code */
var $dlg = $("#objectid");
$dlg.dialog({ autoOpen: false, height: 680, width: 800, modal: true, resizable: false }); $dlg.dialog('open');

 

 

Tags:

JQuery