Dialog is shown itself when changing size of not visible dialog

Dialog is shown itself when changing size of not visible dialog

I have following code that is run every time user rotates mobile phone (so screen width and height are changed) to calculate proper width and height all widgets:

  1. $( "#dialog1" ).dialog({ height: Math.round(screen.availHeight * 0.7)});
  2. $( "#dialog1" ).dialog({ width: Math.round(screen.availWidth * 0.7) });

I noticed that after a few seconds dialog is shown but function

  1.  $( "#dialog1" ).dialog("open");

is not called.

To prevent this I need to use following code


  1. $( "#dialog1" ).dialog({ height: Math.round(screen.availHeight * 0.7)});
  2. $( "#dialog1" ).dialog({ width: Math.round(screen.availWidth * 0.7) });
  3. if(! $("#dialog1").is(":visible")) {
  4.       $( "#dialog1" ).dialog( "close" );
  5. }


Is this right that changing dialog properties makes it visible ?