为什么我的onchange功能不起作用?

时间:2016-01-06 14:54:14

标签: javascript ruby-on-rails

我是ruby的新手并试图在这里调用js函数onchange但是没有工作而没有得到合适的答案。

= f.select :amendment_type, [['Renewal','renewal'],['Lease Amendment Agreement','Lease Amendment Agreement'],['Expansion','Expansion'],['Storage','Storage'],['Parking','Parking'],['Other(for me to fill in)','Other']], class: "amendment_type input", style: "width: 450px;", onchange: "alert('hello')"

1 个答案:

答案 0 :(得分:1)

select方法参数为:

  

select(method,choices = nil,options = {},html_options = {},& block)

您已针对options使用html_options,因此您必须将代码替换为:

= f.select :amendment_type, [['Renewal','renewal'],['Lease Amendment Agreement','Lease Amendment Agreement'],['Expansion','Expansion'],['Storage','Storage'],['Parking','Parking'],['Other(for me to fill in)','Other']], {}, class: "amendment_type input", style: "width: 450px;", onchange: "alert('hello')"