0

我有一个用这样的HAML文件编写的表格

= form_tag "ratings_form", movies_path, :method => :get do
  Include: 
  - @all_ratings.each do |rating|
    = rating 
    = check_box_tag "ratings[#{rating}]", 'yes', @ratings.keys.include?(rating)
  = submit_tag 'Refresh'

我想给每个表单提交按钮一个特定的id

我检查了文档,发现给定的参数

form_tagsubmit_tag 不包含 id 。


正确的答案是添加 :id => "id_u_want" 到任何标签,显然它会在我做的时候起作用

= form_tag movies_path, :id => "ratings_form" , :method => :get do
  Include: 
  - @all_ratings.each do |rating|
    = rating 
    = check_box_tag "ratings[#{rating}]", 'yes', @selected_ratings.keys.include?(rating)
  = submit_tag 'Refresh' , :id => "ratings_submit"
4

1 回答 1

1

试试看:id=>"someid"它是否适合你。

于 2012-10-29T14:07:31.863 回答