.js中的Link_to.erb文件

link_to in .js.erb file

本文关键字:erb 文件 to 中的 Link js      更新时间:2023-09-26

由于某些原因,当我在show.js.erb文件中使用link_to时,javascript不起作用…

如此:

$(".commentvotecount<%= params[:commentid]%>").html("<%= positiveVoteCount = @comment.plusminus %>");

这并不:

$(".commentvotecount<%= params[:commentid]%>").html("<%= positiveVoteCount = @comment.plusminus %> <%= link_to 'About', '/about' %>");

怎么了?

谢谢。

使用escape_javascript来转义引号

$(".commentvotecount<%= params[:commentid]%>").html("<%= escape_javascript link_to('About', '/about') %>");