javascript - relocate dialog box after automatic resize in jquery - Stack Overflow

I have a dialog box that displays a dynamic-sized form. I currently get the dialog box to resize automa

I have a dialog box that displays a dynamic-sized form. I currently get the dialog box to resize automatically with the following code. What I would like it to do is to auto relocate the dialog box after resize event occurs. This is because the dialog box resizes its width, and I would like it to remain centered in the page afterword.

  $("#form-div").dialog({
      autoOpen: false,
      width: "auto",
      height: "auto",
      resize: "auto",
      modal: true
  });

  $("#show-form-button").click(function() {
      $("#form-div").dialog("open");
  });

Edit:

Just to be clear

The dialog box displays a form. After the form is displayed, additional fields may be added to the form, causing it to no longer fit in the original dialog box. The " resize: 'auto' " option automatically takes care of this and resizes the dialog box. I want the dialog box to be centered after it is auto-resized.

I have a dialog box that displays a dynamic-sized form. I currently get the dialog box to resize automatically with the following code. What I would like it to do is to auto relocate the dialog box after resize event occurs. This is because the dialog box resizes its width, and I would like it to remain centered in the page afterword.

  $("#form-div").dialog({
      autoOpen: false,
      width: "auto",
      height: "auto",
      resize: "auto",
      modal: true
  });

  $("#show-form-button").click(function() {
      $("#form-div").dialog("open");
  });

Edit:

Just to be clear

The dialog box displays a form. After the form is displayed, additional fields may be added to the form, causing it to no longer fit in the original dialog box. The " resize: 'auto' " option automatically takes care of this and resizes the dialog box. I want the dialog box to be centered after it is auto-resized.

Share Improve this question edited Nov 12, 2010 at 0:09 Curtor asked Nov 11, 2010 at 23:04 CurtorCurtor 7372 gold badges9 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

According to the docs there is a resizeStop hook after resizing is plete. So you should be able to do something like this:

$("#form-div").dialog({
      autoOpen: false,
      width: "auto",
      height: "auto",
      resize: "auto",
      modal: true,
      resizeStop: function(event, ui) {
        jQuery(this).dialog('option','position','center');
      }
 });

 $("#show-form-button").click(function() {
     $("#form-div").dialog("open");
 });

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745271199a4619757.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信