带有 simple_form 的按钮内的 HTML 代码 [英] HTML code inside buttons with simple_form

查看:39
本文介绍了带有 simple_form 的按钮内的 HTML 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Rails 的新手,刚发现 simple_form gem.我用引导程序支持安装了它,但现在我无法让这段代码按照我想要的方式工作

I'm new to rails, and just found the simple_form gem. I installed it with bootstrap suport, but now I can't get this code to work the way I want it

<%= f.button :submit, "<i class='icon-ok icon-white'></i> Save", class: "btn btn-primary" %>

我只想将图标放在按钮内,但是当我这样做时,它会向我显示一个带有文本<i class='icon-ok icon-white'></i></i>的按钮.保存'

I just want to put the icon inside the button, but when I do this, it shows me a button with the text '<i class='icon-ok icon-white'></i> Save'

我也尝试过

<%= f.button :submit, class: "btn btn-primary" do %><i class="icon-ok icon-white"></i> Save<% end %>

但没有成功.如何使用 simple_form gem 在按钮内添加一些 HTML?

But with no success. How can I add some HTML inside the button with simple_form gem?

推荐答案

不要使用 content_tag.以下工作:

Don't use content_tag. The following works:

  <%= button_tag(type: 'submit', class: "btn btn-primary") do %>
    <i class="icon-ok icon-white"></i> Save
  <% end %>

这篇关于带有 simple_form 的按钮内的 HTML 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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