title: Script not work after redirect in Rails
body: <p>I have a clear button on my page with coffee script </p>
  
  <p>html</p>
  
  <pre><code>&lt;div class="containerNew"&gt;
  &lt;%= form_for @customer, :url =&gt; customers_path do |f| %&gt;
  &lt;table id="createNewCustomer"&gt;
      &lt;tr&gt;
          &lt;td colspan="2"&gt;Input&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="title"&gt;
              &lt;%= f.label :machine_id, "Error Machine:" %&gt;
          &lt;/td&gt;
          &lt;td class="content"&gt;
              &lt;%= select("customer", "machine_id", Machine.all.collect {|m| [ m.name, m.id ] }, { include_blank: false }) %&gt;  
          &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td class="title"&gt;
              &lt;%= f.label :error_info, "Error Info:" %&gt;
          &lt;/td&gt;
          &lt;td class="content"&gt;
              &lt;%= f.text_area :error_info %&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;div class="bottomBtnArea"&gt;
      &lt;%= f.submit "Submit" , class:"button btn btn-primary" %&gt;
      &lt;input type="button" name="clear" value="clear" id="clearBtn" class="btn btn-default"&gt;
  &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>  </p>
  
  <p>coffee</p>
  
  <pre><code>$ -&gt;
    $('#clearBtn').click -&gt;
      $("#customer_machine_id").get(0).selectedIndex = 0
      $("textarea").val("")
  </code></pre>
  
  <p>It works well when I directly access this page's url which is <code>localhost:3000/customers/new</code></p>
  
  <p>But it can't work when I use the nav link to access this page</p>
  
  <pre><code>&lt;%= link_to "Add", new_customer_path %&gt;
  </code></pre>
  
  <p>I use chrome to debug my script, it seems that it didn't go into the function block when I use nav to access this page and then click the clear button. Script file seems not being loaded. I couldn't figure out why it happens.</p>