Rails 话说 html 标签的 id 值可以设置多个吗?怎么改变 simple-form input 的 id 值?

mayday · January 06, 2013 · Last by mayday replied at January 06, 2013 · 5888 hits

已知 class 属性可以设置多个 like <div class="one two"></div>不知道 id 值能不能设置多个? 如果不能的话怎么才能改变 simple-form 里 input 默认生成的 id 值? 我这样做没有效果<%= f.input :id => "add"%>

,,,难道没人碰到这个问题。。。。

:label_html => {:id => "add-label"}
:input_html => {:id => "add-input"}
:wrapper_html => {:id => "add-wrapper"}

既然是 id,肯定是唯一的,不然叫 id(identification)干嘛。

如果要改 simple_form 生成的 id,应该这样做:

<%= f.input :title, input_html: { id: 'your_id' } %>

Get it! 没有认真读 simple-form 的文档。 谢了

You need to Sign in before reply, if you don't have an account, please Sign up first.