【问题标题】:how to use link with glyphicon rails 4如何使用与 glyphicon rails 4 的链接
【发布时间】:2015-10-10 18:21:27
【问题描述】:

我想要和这个一样的效果

                <div id='async_btn',  class="btn" href="#modal-container-340088"  data-toggle="modal"><%= image_tag "msg.jpg" %></div>

但带有字形信封。我该怎么做?

我试过了:

<%= link_to '<span class="glyphicon glyphicon-envelope"></span>'.html_safe, { :id => 'async_btn', :class => 'btn', 'data-toggle' => 'modal', 'data-target' => '#modal-container-340088'} %>

但它不起作用 - 即未呈现模态

【问题讨论】:

标签: ruby-on-rails twitter-bootstrap


【解决方案1】:

带有link_to ... .html_safe 的代码呈现错误的href 属性。这样可以防止模态窗口出现。

你可以只使用 html:

<a href='#' id="async_btn" class="btn" data-target="#modal-container-340088"  data-toggle="modal">
    <span class="glyphicon glyphicon-envelope" />
</a>

但如果你真的需要使用erb,试试这个:

<%= link_to "#", { :id => 'async_btn', :class => 'btn', 'data-toggle' => 'modal', 'data-target' => '#modal-container-340088'} do %>
  <span class="glyphicon glyphicon-envelope" />
<% end %>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    相关资源
    最近更新 更多