[英]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.我有一个 Rails 应用程序,其中包含引导程序按钮中的链接。
<td>
<button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span>
<%= link_to 'Details', user_story %>
</button>
</td>
The HTML shows up properly, and the link is assigned correctly in the anchor tags: HTML 正确显示,并且在锚标记中正确分配了链接:
<td><button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span> <a href="/user_stories/1">Details</a>
</button>
</td>
It works in chrome but not in Firefox or IE.它适用于 chrome,但不适用于 Firefox 或 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?但是,当我删除引导程序样式时,link_to 函数确实可以工作...如何在我的页面上保留引导程序样式并保持跨浏览器兼容性? Or is there a way to force rails to assign the anchor tags around the button?或者有没有办法强制 rails 分配按钮周围的锚标记?
for example: <td><a href="/user_stories/1"><button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span> Details</button></a></td>
例如: <td><a href="/user_stories/1"><button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span> Details</button></a></td>
Update: Now in firefox but not in IE it works using:更新:现在在 Firefox 中而不是在 IE 中,它可以使用:
<% link_to user_story do %>
<button class="btn btn-default"><span class="glyphicon glyphicon-eye-open"></span> Details</button>
<% end %>
It is not valid HTML to have a link inside of a button.在按钮中包含链接不是有效的 HTML。 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.