onchange事件没有出现在rails应用程序中

时间:2016-08-02 16:35:16

标签: javascript jquery ruby-on-rails

我在Application.html.erb中有这段代码

<head>
  <title>SpreemoCodetest</title>
    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
<script>
    function findDocs() {
    $.get("/appointments/list_doctors");
    }
</script>
</head>

我在部分

中有这个collection_select
<%= collection_select(:appointment, :ailment, AilmentsSpecialties.all, :id, :ailment, :prompt => 'select an ailment', html_options: {:onChange => "findDocs();"})%>

部分出现select标签出现我在渲染的html中没有看到我的onchange功能。

1 个答案:

答案 0 :(得分:0)

试试这个。

<%= collection_select(:appointment, :ailment, AilmentsSpecialties.all, :id, :ailment, { :prompt => 'select an ailment' }, { :onChange => "findDocs();" })%>