title: jquery mobile: add event handler to page dialog close button
body: <p>Open a page in dialog style, the close button is added by default. Is there a way to catch the click event of the close button of the dialog page. I like to invoke a callback before the dialog page is closed.</p>
  
  <pre><code>&lt;div data-role="page" id="page1"&gt;
  
      &lt;div data-role="header" data-position="fixed" data-tap-toggle="true" &gt;
          &lt;h1&gt;Page 1&lt;/h1&gt;
      &lt;/div&gt;
  
      &lt;div role="main" class="ui-content"&gt;
          This is Page1.
  
          &lt;a href="#" class="ui-btn ui-corner-all" onclick="showDialog();"&gt;Show Dialog&lt;/a&gt;
  
      &lt;/div&gt;
  
      &lt;script&gt;
          function showDialog() {
              $(":mobile-pagecontainer").pagecontainer("change", "#page2", { role: "dialog" } );
  
          }
     &lt;/script&gt;
  
  &lt;/div&gt;
  
  
  &lt;div data-role="page" id="page2"&gt;
  
      &lt;div data-role="header" data-position="fixed" data-tap-toggle="true" &gt;
          &lt;h1&gt;Dialog&lt;/h1&gt;
      &lt;/div&gt;
  
      &lt;div role="main" class="ui-content"&gt;
  
          This is Dialog
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The pagecontainerhide event can be used. but it did not work for ajax. If the dialog page is dynamically created in DOM, the ui.prevPage is not defined for the hide event.</p>
  
  <p>Thanks for any help.</p>