将 Bootstrap 图标添加到 Ruby on Rails 中的按钮 [英] Adding Bootstrap icon to button in Ruby on Rails

查看:30
本文介绍了将 Bootstrap 图标添加到 Ruby on Rails 中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 ruby​​ on rails 中为按钮添加一个图标.目前我尝试了以下方法:

I want to add an icon to a button in ruby on rails. Currently I've tried the following:

<%= button_to raw("<i class=\"icon-arrow-up\"></i>"),
{:controller => 'events', :action => "upvoteEvent", :method => "put",
:id => @event.id, :uid => current_user.id},
{:class => "btn btn-success"}%>

产生以下html:

<form action="/events/upvoteEvent?id=17&amp;method=put&amp;uid=7" class="button_to" method="post"><div><input class="btn btn-success" type="submit" value="<i class="icon-arrow-up"></i>" /><input name="authenticity_token" type="hidden" value="FsVUPiYl0cK666pn8hqo6AU9/HK0CweZ/nsXqwOWZzU=" /></div></form>

我遵循了此处发布的解决方案:https://stackoverflow.com/a/10468935/1385324,但这对我不起作用.我还测试了 Bootstrap CSS 是否正常工作,只需在网站的其他任何位置插入一个图标即可.

I've followed the solution posted here: https://stackoverflow.com/a/10468935/1385324, but it won't work for me. I have also tested that the Bootstrap CSS is working, by simply inserting an icon anywhere else on the site.

感谢您的帮助!

推荐答案

感谢你们的帮助,最终修改了我自己的 html 输出使其工作:

Thanks for your help guys, ended up with modifying my own html-output which made it work:

<form action="/events/upvoteEvent?id=<%= @event.id.to_s%>&amp;method=put&amp;uid=<%= current_user.id.to_s%>" class="button_to" method="post">
    <button type="submit" value="upvote" class="btn btn-success">
        <i class="icon-arrow-up"></i>
    </button>
</form>

这篇关于将 Bootstrap 图标添加到 Ruby on Rails 中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆