开发者

Using autofocus and text_field form helpers in Rails

How do I include the 'autofocus' attri开发者_C百科bute on an HTML5 form using the text_field form helper in Rails?

e.g. <%= f.text_field :email %> Where does autofocus go?

Thanks


f.text_field :email, autofocus: true


This will work:

text_field_tag :reseller, '', autofocus: true

Note the empty value argument.


<%= f.text_field :email, nil, :autofocus => true %> will work.

similarly, if you want to use other HTML5 attributes and CSS classes, you can write :

<%= f.text_field :email, nil, :autofocus => true, :placeholder => "Your email Here", :class => "active", :style => "color: #333;" %>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜