Animate jQuery UI dialog auto resize
Asked Answered
D

3

6

I have a dialog with a dynamic form inside that can increase the height of the dialog. autoResize is set to true, width is 500. Is there any way to animate the dialog resize when more content is added?

Duren answered 29/7, 2011 at 15:14 Comment(0)
D
4

Originally I was using .show('fade') and the size of the dialog would jump whenever .show was called. When using the effect .show('fast') or .show('slow'), the dialog is resized in a sliding fashion which works for me.

Duren answered 1/8, 2011 at 13:13 Comment(0)
W
16

Animating dialog size, while staying in the center of the screen

jQuery("#dialog").dialog("widget").animate({
    width: '400px', 
    height: '110px'
  }, {
  duration: 500,
  step: function() {
    jQuery("#dialog").dialog('option', 'position', 'center');
  }
});
Waac answered 13/12, 2011 at 23:43 Comment(1)
when done resizing/enlarging, when I add new content via html( ) my content is cropped to the height of the previous size...Neonatal
D
4

Originally I was using .show('fade') and the size of the dialog would jump whenever .show was called. When using the effect .show('fast') or .show('slow'), the dialog is resized in a sliding fashion which works for me.

Duren answered 1/8, 2011 at 13:13 Comment(0)
B
1

When i was using @Steven's answer i have issues with content size, like @jedierikb said in comment. So i created this code and it works.

$(dialogSel).dialog("widget").animate({
    width: 100,
    height: 200
}, {
    duration: 200,
    step: function (now, tween) {
        if (tween.prop == "width") {
            $(dialogSel).dialog("option", "width", now);
        } else {
            $(dialogSel).dialog("option", "height", now);
        }
    }
});
Birthday answered 27/8, 2014 at 19:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.