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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -