Rails and bootstrap - Add HTML tags to a submit button text
ruby-on-rails, twitter-bootstrap
Solution
Thanks to ismaelga, I found this SO question.
This is the solution :
<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
<i class="icon-ok icon-white"></i> Save
<% end %>
Problem
I have a form for a like/unlike button using ajax : ``` = form_for like, :html => { :method => :delete}, :remote => true do |f| = f.submit pluralize(@video.likes.count, 'like'), :class => "btn btn-warning btn-mini", "data-disable-with"=> "Just a moment..." ``` The form works perfectly. I would like to add an icon in front of the text in the submit button. The haml code for adding the icon is the following (twitter bootstrap) : ``` %i.icon-heart.icon-white ``` Is there a way to add this html to the button? I tried adding it as plain html, but rails rendered it as text. UPDATE I have manage to encapsulate the submit button in a span class which contains the icon and the appropriate styling. I now need to remove every styling on the button... ``` %span.btn.btn-danger.btn-mini %i.icon-heart.icon-white = f.submit pluralize(@video.likes.count, 'like') ```