title: Why do coffeescript/jquery functions not trigger on DOM elements loaded via ajax, and how to fix?
body: <p>In a Rails 3.2 app I have a coffeescript function that toggles a css class when a link is clicked.</p>
  
  <pre><code>#coffeescript
  jQuery -&gt;
    $(".toggle-link").click -&gt;
      $(this).toggleClass "selected"
  
  #view
  &lt;%= link_to "toggle", my_path, class: "toggle-link" %&gt;
  </code></pre>
  
  <p>This works fine.</p>
  
  <p>But if I move the link into an ajaxified partial, e.g. for pagination, the jquery toggle stops working.</p>
  
  <p>Why is this?</p>
  
  <p>And how can it be fixed?</p>