I have a JQuery UI dialog popup that displays a form. By selecting certain options on the form new options will appear in the form causing it to grow taller. This can lead
If you need it to work in IE7, you can't use the undocumented, buggy, and unsupported {'width':'auto'}
option. Instead, add the following to your .dialog()
:
'open': function(){ $(this).dialog('option', 'width', this.scrollWidth) }
Whether .scrollWidth
includes the right-side padding depends on the browser (Firefox differs from Chrome), so you can either add a subjective "good enough" number of pixels to .scrollWidth
, or replace it with your own width-calculation function.
You might want to include width: 0
among your .dialog()
options, since this method will never decrease the width, only increase it.
Tested to work in IE7, IE8, IE9, IE10, IE11, Firefox 30, Chrome 35, and Opera 22.