title: How to create a jQuery Mobile Popup Alert mechanism?
body: <p>I have been trying for hours to implement this and I am close but not there.</p>
  
  <p>The goal is simple. To have a functional popup alert that can be used from everywhere within an app. </p>
  
  <p>For example I have some code where I want to show a popup after a simple if test:</p>
  
  <pre><code>if (message.type == "Error") { //lets show a popup !!!
  
      $.mobile.changePage( "alert.html", {
      type: "post", 
      data: "alert_title="+message.type+"&amp;alert_message="+message.content,
      transition: "pop",
      role: "dialog",
      reloadPage:true
  });
  </code></pre>
  
  <p>As you can see I am passing in some custom data.</p>
  
  <p>Here is the code for my alert page:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;title&gt;Alert&lt;/title&gt;
          &lt;!--#include virtual="header.inc" --&gt;
  
      &lt;script&gt;
      alert("test");
      $('#alert_dialog').live('pageinit', function (event) {
      $("#alert_title").text($.urlParam('alert_title'));
      $("#alert_body").text($.urlParam('alert_message'));
      });
      &lt;/script&gt;
  
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;div data-role="page" id="alert_dialog"&gt;
          &lt;div data-role="header"&gt;
              &lt;h1&gt;Alert&lt;/h1&gt;
  
          &lt;/div&gt;
  
          &lt;div data-role="content"&gt;
              &lt;h1 id="alert_title"&gt;alert title&lt;/h1&gt;
              &lt;p id="alert_body"&gt;alert body&lt;/p&gt;
              &lt;a href="#" data-role="button" data-rel="back"&gt;OK&lt;/a&gt;        
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>The problem I am running is that no javascript is getting executed on <code>alerts.html</code> page since it is injected to the DOM. Why would jQuery Mobile even allow us to send POST data using  <code>$.mobile.changePage</code> when we cannot possibly use it?</p>
  
  <p>Any help or suggestions?</p>