如何将自定义html属性data-uk-toggle
粘贴到simple_form标签中,如
<span class="uk-button" data-uk-toggle="{target:'.my-class'}">...</span>
我试过
<%= g.label :self_estimation, class: 'km-180-label', input_html: { "data-uk-toggle" => "{target:'.my-class'}" } %>
但它不起作用
答案 0 :(得分:0)
你需要做的是这样的事情:
<%= g.input :self_estimation, label_html: { class: 'km-180-label', :data-uk-toggle => "{target:'.my-class'}" } %>
您可以在Simple Form
找到更多详细信息答案 1 :(得分:0)
尝试:
<%= g.input :self_estimation, label_html: { class: 'km-180-label', "data-uk-toggle" => "{target:'.my-class'}" } %>
OR
<%= g.input :self_estimation, label_html: { class: 'km-180-label', data: {uk_toggle: "{target:'.my-class'}"} } %>
OR
<%= g.label :self_estimation, :class => 'km-180-label', "data-uk-toggle" => "{target:'.my-class'}" %>
OR
<%= g.label :self_estimation, :class => 'km-180-label', data: {uk_toggle: "{target:'.my-class'}"} %>
答案 2 :(得分:-1)
这样您就可以添加自定义属性。
<%= g.label :self_estimation, :class => 'km-180-label', :"data-uk-toggle" => "{target:'.my-class'}" %>