我有一个用 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
我检查了documentation并发现了给
的参数form_tag 或 submit_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"
答案 0 :(得分:1)
尝试:id=>"someid"
看看它是否适合你。