【发布时间】:2016-02-29 18:42:50
【问题描述】:
我的导轨中有以下选择下拉菜单。我正在遵循 API 中的语法(http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-collection_select):
collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {})
<%= collection_select(:sources, :source_id, Source.all, :id, :name, :include_blank => "Please select a source...", html_options = {:onchange => "updateTextArea()"} ) %>
function updateTextArea(){
alert('source changed')
}
当我不包含 html_options 时,我可以让下拉菜单很好地显示来自数据库的值。但是,我一直在尝试执行 onchange 操作。
【问题讨论】: