title: Run a function after loading jQuery dialog
body: <p>This may be a simple question, but I can't quite get it to work. I'm using a jQuery dialog to display a form loaded from another page on my website. The user clicks on a link, which fires up the dialog. What I'm trying to do is to run a function after loading the HTML into the dialog. Here is my code to load the dialog:</p>
  
  <pre><code>$(document).ready(function () {
      $(".openDialog").live("click", function (e) {
          e.preventDefault();
  
          $("#dialogBox").dialog({
              title: $(this).attr("data-dialog-title"),
              close: function() { $(this).remove() },
              modal: true
          })
          .load(this.href);
      });
  
      $(".close").live("click", function (e) {
          e.preventDefault();
          $(this).closest(".dialog").dialog("close");
      });
  });
  </code></pre>
  
  <p>I have a function myFunction() that I want to call when the HTML is loaded into the dialog. After looking around for quite a bit, I tried specifying the function in .load, like this:</p>
  
  <pre><code>.load(this.href, myFunction());
  </code></pre>
  
  <p>I also tried using the open event, like this:</p>
  
  <pre><code>open: myFunction(),
  </code></pre>
  
  <p>What am I doing wrong?</p>