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')
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 %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With