title: best practice for opening and/or initializing jquery ui dialog
body: <p>There are two ways to open a jquery dialog:</p>
  
  <p>1) Set the <code>autoOpen=true</code> when initializing a dialog</p>
  
  <p>2) After initialization (with <code>autoOpen = false</code>), call <code>$("#id").dialog("open");</code></p>
  
  <p>At the moment, in my code, whenever a user clicks a button, a modal dialog opens by using the first method. On "Ok" or "Cancel" the dialog is closed <code>$(this).dialog("close");</code></p>
  
  <p>Is it bad that on every click the dialog is opened using autoOpen=true ? In other words, is it bad that the dialog is reinitialized on every click ?</p>
  
  <p>From a performance, point of view, will reinitializing the dialog on every click cause problems such as dialog events being registered multiple times ?</p>
  
  <p>What is the jquery best practice for this ?</p>
  
  <p>Code:</p>
  
  <pre><code>$("#button").on("click",function(){
  
     $("#dialogHello").dialog({
        modal: true,
        autoOpen: true,
        buttons: [
          {   "text" : "Ok", "click" : function() { $(this).dialog("close"); } },
          {   "text" : "Cancel", "click" : function(){ $(this).dialog("close"); } }
        ]
     });
  
  });
  </code></pre>