Gcap
Gcap

Reputation: 378

Rails 4 - link_to not working in firefox or IE (also bootstrap design not showing)

I have a rails app that has links included in bootstrap buttons.

<td>
<button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span>&nbsp;
<%= link_to 'Details', user_story %>
</button>
</td>



The HTML shows up properly, and the link is assigned correctly in the anchor tags:

<td><button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span>&nbsp;<a href="/user_stories/1">Details</a>
</button>
</td>



It works in chrome but not in Firefox or IE. However when I remove the bootstrap styling, the link_to function does work... How can I keep bootstrap styling on my pages and keep cross browser compatibility? Or is there a way to force rails to assign the anchor tags around the button?
for example: <td><a href="/user_stories/1"><button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span>&nbsp;Details</button></a></td>


Update: Now in firefox but not in IE it works using:

<% link_to user_story do %>
    <button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span>&nbsp;Details</button>
<% end %>

Upvotes: 2

Views: 703

Answers (1)

Brad Werth
Brad Werth

Reputation: 17647

It is not valid HTML to have a link inside of a button. It is easy to make links look like buttons, though. Try something like:

<td>
  <%= link_to user_story, class: 'btn btn-default' do %>
    <span class="glyphicon glyphicon-eye-open"></span> Details 
  <% end %>
</td>

Upvotes: 1

Related Questions