title: JQuery Mobile: Run javascript method on new page
body: <p>I have an app that allows users to win prizes. To win a prize they need to get to a page like this: <code>www.myUrl.com#isAWinner</code> where <code>#isAWinner</code> is my mobile page. I am worried that someone will think of just entering that url and going directly to the winner page without actually winning. To fix this I attempted to do this:</p>
  
  <pre><code>&lt;!-- Show this if the user is a winner --&gt;
  &lt;div id = "isAWinner" data-role = "page"&gt;
      &lt;p&gt;YOU WIN!!!&lt;/p&gt;
      &lt;!-- Invisible link --&gt;
      &lt;a href = "#beforeLogin" id = "goBack" class = "InvisibleLinks"&gt;&lt;/a&gt;
      &lt;!-- Ensures that the user does not just enter #isAWinner to the end of the URL --&gt;
      &lt;script type="text/javascript"&gt; reallyAWinner()&lt;/script&gt;
  &lt;/div&gt;
  
  function reallyAWinner () {
      alert(isAWinner);
      //Check to see if they really are a winner
      if (isAWinner == false) {
          //Not really a winner. Send back to login
          $('#goBack').click();
      }
  }
  </code></pre>
  
  <p>The problem is that the <code>alert</code> is hit when the page initially loads, but if i try to go to that URL afterwords, then the method is not hit again. </p>
  
  <p>Am I not understanding how JQuery mobile works? Will it only hit that <code>reallyAWinner()</code> method when the whole HTML page loads, and not when the <code>isAWinner</code> page loads? If so, is there another way I can check if the user is really a winner only when the <code>isAWinner</code> page loads?</p>
  
  <p><strong>Edit</strong>: here is a little more info. When I enter the method initially without loading the first page, the alert in <code>reallyAWinner()</code> will fire before an alert I have in my <code>document.ready</code> method, making the <code>$('#goBack').click();</code> not work (Because mobile is not loaded)</p>