I have a clear button on my page with coffee script
html
<div class="containerNew">
<%= form_for @customer, :url => customers_path do |f| %>
<table id="createNewCustomer">
    <tr>
        <td colspan="2">Input</td>
    </tr>
    <tr>
        <td class="title">
            <%= f.label :machine_id, "Error Machine:" %>
        </td>
        <td class="content">
            <%= select("customer", "machine_id", Machine.all.collect {|m| [ m.name, m.id ] }, { include_blank: false }) %>  
        </td>
    </tr>
    <tr>
        <td class="title">
            <%= f.label :error_info, "Error Info:" %>
        </td>
        <td class="content">
            <%= f.text_area :error_info %>
        </td>
    </tr>
</table>
<div class="bottomBtnArea">
    <%= f.submit "Submit" , class:"button btn btn-primary" %>
    <input type="button" name="clear" value="clear" id="clearBtn" class="btn btn-default">
</div>
<% end %>
coffee
$ ->
  $('#clearBtn').click ->
    $("#customer_machine_id").get(0).selectedIndex = 0
    $("textarea").val("")
It works well when I directly access this page's url which is localhost:3000/customers/new
But it can't work when I use the nav link to access this page
<%= link_to "Add", new_customer_path %>
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.
 
     
     
     
    