title: Rails 4 TurboLinks and jQuery Dynamic Links Not Playing Nice
body: <p>I am developing an application in Rails 4.0 and I'm having an issue with turbolinks not playing nice with some jQuery code I have.  I have  a Quote model that has a related QuoteItems model.  I am using accepts_nested_attributes_for and some jQuery to populate the line items form.</p>
  
  <p>When I click on a link bringing me to the new_quote_path,  The dynamic link doesn't fire the javascript code.  When I refresh the page,  the form WORKS GREAT.  I like turbolinks as it is super fast, but not sure how to get this to work in development.  Here's some code.</p>
  
  <p>in quotes.js.coffee</p>
  
  <pre><code>jQuery -&gt;
    $('form').on 'click', '.remove_line_items', (event) -&gt;
    $(this).prev('input[type=hidden]').val('1')
    $(this).closest('fieldset').hide()
    event.preventDefault()
  
  $('form').on 'click', '.add_fields', (event) -&gt;
    time = new Date().getTime()
    regexp = new RegExp($(this).data('id'), 'g')
    $(this).before($(this).data('fields').replace(regexp, time))
    event.preventDefault()
  </code></pre>
  
  <p>Quotes view new.html.erb</p>
  
  <pre><code>&lt;%= form_for @quote, :class =&gt; "hello" do |f| %&gt;
      &lt;fieldset&gt;
        &lt;p&gt;
          &lt;%= f.label :quote_date, "Date of Quote" %&gt;  &lt;br/&gt;
          &lt;%= f.text_field :quote_date %&gt;
        &lt;/p&gt;
  
        &lt;p&gt;
          &lt;%= f.label :good_through %&gt; &lt;br/&gt;
          &lt;%= f.text_field :good_through %&gt;
        &lt;/p&gt;
  
        &lt;p&gt;
          &lt;%= f.label :quote_number %&gt;&lt;br/&gt;
          &lt;%= f.text_field :quote_number %&gt;
        &lt;/p&gt;
        &lt;p&gt;
          &lt;%= f.label :customer_id, "Customer" %&gt;&lt;br/&gt;
          &lt;%= select(:quote, :customer_id, Customer.all.collect {|c| [ c.fname, c.id ] }, :prompt =&gt; "Select Customer") %&gt;
        &lt;/p&gt;
  
        &lt;%= f.fields_for :quote_items do |builder| %&gt;
            &lt;%= render 'quote_item_fields', :f =&gt; builder %&gt;
        &lt;% end %&gt;
  
        &lt;%= link_to_add_fields "Add Line Item", f, :quote_items %&gt;
  
        &lt;p&gt;
          &lt;%= f.submit %&gt;
        &lt;/p&gt;
      &lt;/fieldset&gt;
  &lt;% end %&gt;
  </code></pre>