Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace submit button with glyphicon in rails

Quick question. I have:

<%= f.submit "Like", class: "btn btn-large btn-primary" %>

and instead of the text reading "like" I would like to replace the whole button with the:

<span class="glyphicon glyphicon-thumb-up"></span>

symbol.

What would be the correct way in rails to replace the submit button with the thumbs up icon but have it do the same thing?

UPDATE

I found this:

<%= button_tag(type: 'submit', class: "btn btn-primary") do %>
  <span class="glyphicon glyphicon-thumbs-up"></span> 
<% end %>

But the only problem is that this still shows the button behind the glyphicon (even if I remove btn btn-primary). Does anyone know how to get rid of the button?

Thank you!

like image 643
MikeHolford Avatar asked Jan 02 '14 12:01

MikeHolford


2 Answers

I found this to work for submitting my form with a button containing only a glyphicon:

<%= button_tag "", type: 'submit', class: "btn btn-default glyphicon glyphicon-ok pull-right" %>

glyphicon class is a checkbox instead of thumbs up, and bootstrap btn styling is default instead of primary, but it should do the same thing.

like image 152
Ian MacDonald Avatar answered Oct 21 '22 11:10

Ian MacDonald


You can add following class to the button to hide button background,

    .like-page{
      background: none;
      border: none;
    }
like image 33
C LOKESH REDDY Avatar answered Oct 21 '22 11:10

C LOKESH REDDY