无法在Rails中使用coffeescript函数

时间:2016-05-28 18:06:36

标签: javascript jquery ruby-on-rails coffeescript

我在rails应用程序中有一个功能,可以从下拉菜单中单击激活。函数在dashboards.js.coffee中的文件已被识别,但下拉列表一直给我错误

Uncaught ReferenceError: chooseManager is not defined

这是包含chooseManager调用的下拉菜单......

   <select id="adminDropDown" onchange= "chooseManager();" class="form-control">
        <% if current_admin.manager_approvals.blank? %>
           <option>No Sub-Accounts added, Add one today!</option>
        <% elsif current_admin.manager_approvals.all? { |ma| ma.manager_approved == false }%>
           <option>No Sub-Accounts approved yet!</option>
        <% else %>
           <% current_admin.manager_approvals.where(manager_approved: true).each do |ma| %>
            <option value="<%= ma.manager_id %>"><%= ma.manager_company %>&nbsp;|&nbsp;<%= number_to_phone(ma.manager_phone) %></option>
        <% end %>
      <% end %>
  </select>

这是coffescript函数......

chooseManager = ->
 managerId = $(this).val()
 $.ajax
 type: 'POST'
 url: 'admins/reportapprovals/manager_select'
 data: manager_id: managerId
return

我不熟悉coffescript,我错过了什么或做错了什么?

0 个答案:

没有答案