Reputation: 4967
I've got a simple rails form, laid out with haml and want to use fontAwesome icons for the actions, instead of "Show, Edit...". So I created this code to put the link inside a fontAwesome'd span:
%td{:width => "7%"}
%span{:class => "fa fa-id-card-o"}= link_to '', log
%span{:class => "fa fa-pencil-square-o"}= link_to "", edit_log_path(log)
%span{:class => "fa fa-trash"}= link_to '', log, method: :delete, data: { confirm: 'Are you sure?' }
It generates this html:
<td width="7%">
<span class="fa fa-id-card-o"><a href="/logs/46"></a></span>
<span class="fa fa-pencil-square-o"><a href="/logs/46/edit"></a></span>
<span class="fa fa-trash"><a data-confirm="Are you sure?" rel="nofollow" data-method="delete" href="/logs/46"></a></span>
</td>
which looks to me as if it should work since the <a>
is inside the <span>
.
However, none of the icons are clickable.
Upvotes: 0
Views: 212
Reputation: 15798
Icon should be inside the <a>
and </a>
. Right now it's empty.
In HAML you will have to do something like this:
= link_to log, method: :delete, data: { confirm: 'Are you sure?' } do
%span{:class => "fa fa-trash"}
It will place span under link and generated html would be something like this <a ...> <span/> </a>
Upvotes: 1