【问题标题】:Achieve rendering of Semantic UI Icon within button_to在 button_to 中实现语义 UI 图标的渲染
【发布时间】:2018-09-22 19:45:57
【问题描述】:

我正在尝试实现一个 button_to,它看起来像一个链接 (class="btn btn-link"),并且它的文本(输入)值是一个语义 UI 图标。我需要按钮以内嵌链接的形式显示。我正在使用语义-ui-rails gem。我的按钮格式如下:

<%= button_to semantic_icon('lightbulb outline'),
                  votes_path,
                  options: {
                      params: {
                          voter_id: current_user.id,
                          target_type: "Comment",
                          target_id: comment.id,
                          value: 1
                      }
                  },
                  class: "btn btn-link",
                  remote: true
    %>

但是,按钮在我的屏幕上显示为 &lt;i class="lightbulb outline icon"&gt;&lt;/i&gt; 而不是渲染灯泡轮廓图标本身。

我必须更改什么才能使按钮表单的输入标记的值正确呈现?

【问题讨论】:

    标签: ruby-on-rails icons semantic-ui


    【解决方案1】:

    试试

    <%= button_to votes_path, class: "btn btn-link", remote: true, params: {
                                                                    voter_id: current_user.id,
                                                                    target_type: "Comment",
                                                                    target_id: comment.id,
                                                                    value: 1
                                                                  } do %>
      <%= semantic_icon('lightbulb outline') %>
    <% end %>
    

    【讨论】:

    • 根据需要呈现图标。现在,该图标将不会呈现内联,而是在我的文本中占据自己的行。 (我已更新问题以反映此要求)。
    • 为了完整起见:我在 "remote: true": form: {style: 'display:inline-block;'} 之后添加了以下内容,并让表单按照我的需要呈现为内联。
    猜你喜欢
    • 1970-01-01
    • 2018-11-22
    • 2021-02-19
    • 1970-01-01
    • 2022-12-17
    • 2019-09-03
    • 2021-04-18
    • 2019-10-05
    • 1970-01-01
    相关资源
    最近更新 更多