title: calling jquery from ajax page
body: <p>I'm having trouble using jQuery with child page</p>
  
  <p>parent.html loads child.html like so: ie user clicks </p>
  
  <pre><code>&lt;a href="#" id="n-email"&gt;
  </code></pre>
  
  <p>JQuery</p>
  
  <pre><code>$('a#n-email').click(function () {
      $.ajax({
          type: "GET",
          url: "/scripts/contact.js",
          dataType: "script"
      });
  
      $('#content').load("child.htm");
  });
  </code></pre>
  
  <p>contact.js</p>
  
  <pre><code>$(function () {
      alert("contact js hit");
  });
  </code></pre>
  
  <p>This occasionally works. But I can't work out the logic of why it works. I've also tried adding a ref to the Jquery on the handler also.  I feel like I'm missing a trick here. </p>
  
  <p>Thanks to jake + lucus. I've got the following working. Needs a refactor, but works</p>
  
  <pre><code>$('#n-email').click(function () {
      var e = this; reset(e);
  
      var mypage = $('#contentemail').load("email.php");
  
      $.ajax({
          type: "GET",
          url: "/scripts/contact.js",
          dataType: "script",
          success: function (mypage) {
              $(document).append(mypage);
          }
      });
  
      $('#contentemail').show();
  
  });
  </code></pre>