代码如下。
<% account_id = @account.id %>
<%= f.select :white_count, options_for_select((1..7), f.object.try(&:white_count)), { label: 'Please select how many fields there are in white', include_blank: '--Select--' }, class: "white-count-#{@water_meter.id}", onchange: 'displayReadingBlocks()' %>
我需要将account_id作为参数传递给javascript函数displayReadingBlocks()。
关于如何执行此操作的任何想法?
答案 0 :(得分:0)
使用字符串插值实现
<%= f.select :white_count, options_for_select((1..7), f.object.try(&:white_count)), { label: 'Please select how many fields there are in white', include_blank: '--Select--' }, class: "white-count-#{@water_meter.id}", onchange: "displayReadingBlocks(#{account_id})" %>