如何将“ uk-toggle”放入rails link_to?

时间:2019-01-07 06:59:54

标签: html ruby-on-rails uikit

我有一个“登录”链接

这是我的代码

<a href="#modal-example" class="uk-float-right" uk-toggle>
 <span uk-icon='icon: user'></span>
 <span>Sign in</span>
 <span uk-icon='icon: chevron-down'></span>
</a>

当我单击“登录”时,将显示模式。

现在,我想将其更改为rails link_to标签。

<%= link_to "#modal-example", class:"uk-float-right", uk-toggle do %>
 <span uk-icon='icon: user'></span>
 <span>Sign in</span>
 <span uk-icon='icon: chevron-down'></span>
<% end %>

3 个答案:

答案 0 :(得分:0)

尝试一下:

<%= link_to class:"uk-float-right", "id": "#modal-example", "data": {"uk-toggle": ""} do %>

#rest of your code

已更新:

<%= link_to class:"uk-float-right", "id": "#modal-example", "data": {"uk-toggle": ""}, "uk-toggle": "" do %>

答案 1 :(得分:0)

完成!

<%= link_to "#modal-example", class:"uk-float-right", "uk-toggle": "" do %>
    <span uk-icon='icon: user'></span>
    <span>Sign in</span>
    <span uk-icon='icon: chevron-down'></span>
    <% end %>

答案 2 :(得分:0)

通常对于布尔属性,您可以传递值true

常用属性为disabled

在您的情况下

<%= link_to "#modal-example", class:"uk-float-right", "uk-toggle" => true do %>
 <span uk-icon='icon: user'></span>
 <span>Sign in</span>
 <span uk-icon='icon: chevron-down'></span>
<% end %>