为什么不是'我的onchange函数不起作用

Why isn't my onchange function working?

本文关键字:onchange 函数 不起作用 我的 为什么不      更新时间:2023-09-26

我是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')"

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')"