title: How to add events to elements appended by AJAX?
body: <p>I load some html using AJAX, this works fine, one of the bits that loads is a contact form which I am trying to intercept the submit event using</p>
  
  <pre><code>$(document).ready(function() {    
      $('contact_form').submit(function() {
          return false;
      });    
  });
  </code></pre>
  
  <p>The above javascript is loaded with the initial page load.</p>
  
  <p>However, when I visit the page and submit the form it follows its default path and follows the regular submit (which works but it is my non-javascript compatability route that I want most users not to follow). I have tried testing <code>.click()</code> events on bits of the page that are initially loaded and similar bits that are loaded using AJAX, the result being that only the elements that were initially loaded with the page execute the <code>.click()</code> event.</p>
  
  <p>I'm guessing that it is the fact that I load the jQuery code before adding the elements to the DOM (I have some <code>&lt;script&gt;</code> tags that load with the initial page load) and this is not regestering the listeners propperly (wild guess, I actually don't really have a clue).</p>
  
  <p>Am I correct in my assumption? And what is the best fix?</p>