Reputation: 5370
For some reason, when I use link_to in my show.js.erb file, the javascript does not work...
This works:
$(".commentvotecount<%= params[:commentid]%>").html("<%= positiveVoteCount = @comment.plusminus %>");
This doesn't:
$(".commentvotecount<%= params[:commentid]%>").html("<%= positiveVoteCount = @comment.plusminus %> <%= link_to 'About', '/about' %>");
What is going wrong?
Thank you.
Upvotes: 3
Views: 2332
Reputation: 29599
use escape_javascript so quotes are escaped.
$(".commentvotecount<%= params[:commentid]%>").html("<%= escape_javascript link_to('About', '/about') %>");
Upvotes: 4