Rails button_to - 将css类应用于按钮 [英] Rails button_to - applying css class to button
本文介绍了Rails button_to - 将css类应用于按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这很愚蠢,但我无法弄清楚如何设计由Rails button_to
创建的输入元素 - 是的,我已经阅读了文档并再次尝试了样品。
This is silly, but I just can't figure out how to style the input element created by Rails button_to
-- and yes, I've read the docs over and over again and tried the samples.
这是我的ERB代码:
Here's my ERB code:
<%= button_to "Claim", action: "claim", idea_id: idea.id, remote: true, class: 'btn btn-small' %>
这会产生以下HTML:
And this yield the following HTML:
<form action="/ideas/claim?class=btn+btn-small&idea_id=4&remote=true" class="button_to" method="post">
<div>
<input data-remote="true" type="submit" value="Claim">
<input name="authenticity_token" type="hidden" value="pU3umgqrDx3WbalfNK10c9H5B5N4OzPpohs4bWW8mow=">
</div>
</form>
尽管我只想要输入
到有 class =btn btn-small
。
帮助?谢谢!
推荐答案
方法的签名 button_to
是
The signature of the method button_to
is
button_to(name = nil, options = nil, html_options = nil, &block)
因此,使用 {}
区分选项
和 html_options
<%= button_to "Claim", {action: "claim", idea_id: idea.id, remote: true}, {class: 'btn btn-small'} %>
这篇关于Rails button_to - 将css类应用于按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文