简体   繁体   中英

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 %>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM