Using Bootstrap Icons with Button_To "Delete" in Rails 3

Using bootstrap icons with button_to delete in rails 3

try this...for example with link_to

<%= link_to (‘<i class=“fa fa-thumbs-up fa-lg”> </i>’).html_safe, vote_path(@image), :method=> :delete, :remote=> true%>

How can I add bootstrap's icon to button_to in rails3

Try using a block

<%= link_to girl, confirm: 'Are you sure?', disable_with: 'deleting...', method: :delete, class: 'btn-mini btn-danger btn' do %>
<i class="icon-pencil icon-white"></i> Destroy
<% end %>

http://apidock.com/rails/v3.2.1/ActionView/Helpers/UrlHelper/button_to

http://apidock.com/rails/v3.2.1/ActionView/Helpers/UrlHelper/link_to

Adding a Twitter Bootstrap button icon to button_to in Rails

It looks like you have an issue with your quotes:

<%= button_to raw("<i class=\"icon-search icon-white\">Add To Cart</i>"), 
line_items_path(product_id: product),
class: "btn btn-success" %>

Enclose the label of the button in double quotes, escape the double quotes in your i tag, and finally, wrap everything into a raw() call to ensure the HTML is properly displayed.

Alternatively you can use html_safe:

<%= button_to "<i class=\"icon-search icon-white\">Add To Cart</i>".html_safe, 
line_items_path(product_id: product),
class: "btn btn-success" %>

good point from @jordanpg: you can't have HTML in the value of a button, so his solution is more appropriate and should get the approved status.
the html_safepart remains valid though.

How to use link_to function on svg icons from bootstrap

Try

<td>
<%= link_to friend, method: :delete, data: { confirm: 'Are you sure?' }
do %>
<svg width="2em" height="2em" viewBox="0 0 16 16" class="bi bi-trash" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4L4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
</svg>
<% end %>
</td>

The friend in the link is the path to the controller action

How to rewrite deleting link_to helper to use it with glyphicon icon?

try this

    <%= link_to user_task_path(current_user, task.id), method: :delete, data: { confirm: 'Are you sure?' }, remote: true do %>
<i class="glyphicon glyphicon-trash"></i>
<% end %>

How to add glyphicons to rails link_to helper - Bootstrap 3

I found the answer to this here

The basic form of a glyph link in rails looks like this:

<%= link_to deals_path, class: "btn btn-default" do %>
<i class="glyphicon glyphicon-euro"></i> Dashboard
<% end %>

Modify as needed. The second example in that link didn't work for me, I assume because I'm using the rails_bootstrap_sass gem? Regardless, the above form worked for me.

Including bootstrap glyphicon in Rails link

I'd do :

<%= link_to signup_path, class: "button" do %>
<i class="glyphicon glyphicon-check"></i>  Sign up
<% end %>

I feel like its clearer.

Nested icons and Rails' link_to or button_to are not working with SLIM

According to the documentation, it should be:

= button_to firefighters_approve_path(entry), class: 'button is-success' do
i.fa.fa-thumbs-up
|Accept

If you use a block, first argument should be a path and block contains name.

Add bootstrap glyph icon to link_to with multiple arguments

You can use link_to with a block as stated in the link_to documentation

You can use a block as well if your link target is hard to fit into the name parameter.

<%= link_to(task_path(task, "task[started_at]" => DateTime.now), :method => :put, :confirm => "Sure?", class: "btn btn-default btn-sm") do |link| %>
<i class="glyphicon glyphicon-play"></i> Start Task
<% end %>


Related Topics



Leave a reply



Submit