javascript - Add icons to link_to in js.erb.html? -
how can add <i class="fa fa-heart-o"></i>
link_to
helper?
$('.like_song').bind('ajax:success', function(){ $(this).parent().parent().find('.vote_count').html('<%= escape_javascript @song.votes_for.size.to_s %>'); $(this).closest('.like_song').hide(); $(this).closest('.votes').html(' <%= link_to "unfavorite", unlike_song_path(@song), remote: true, method: :get, class: 'unlike_song' %>'); });
what i'm trying create icon (button) favorite/unfavorite.
you can passing in block, <%= link_to path, options %> ... <% end %>
, ... can add tag, in case:
<%= link_to unlike_song_path(@song), remote: true, method: :get, class: 'unlike_song' %> <i class="fa fa-heart-o"></i> <% end %>
note "unfavorite" inside tags, isn't needed, content inside tags i
icon.
Comments
Post a Comment