简体   繁体   English

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

[英]Why isn't my onchange function working?

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

The select method parameters are: select方法参数为:

select(method, choices = nil, options = {}, html_options = {}, &block) select(方法,选项=无,选项= {},html_options = {},&block)

You've used options against html_options , so you have to replace your code with: 您已经针对html_options使用了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')"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM