Javascript js.erb文件中链接到帮助器的嵌套引号
我试图在我用于ajax请求的vots.js.erb文件中实现这一点,但它没有吐出任何东西Javascript js.erb文件中链接到帮助器的嵌套引号,javascript,ruby-on-rails,ajax,Javascript,Ruby On Rails,Ajax,我试图在我用于ajax请求的vots.js.erb文件中实现这一点,但它没有吐出任何东西 <% if current_user && @micropost.has_evaluation?(:votes, current_user) %> $("#vote<%= @micropost.id %> a").html('<%= link_to "<i class='fa fa-heart fa-3x'></i>".html_
<% if current_user && @micropost.has_evaluation?(:votes, current_user) %>
$("#vote<%= @micropost.id %> a").html('<%= link_to "<i class='fa fa-heart fa-3x'></i>".html_safe, vote_micropost_path(@micropost, type: "down"), :method => :post, :remote => true %>')
<% else %>
$("#vote<%= @micropost.id %> a").html('<%= link_to "<i class='fa fa-heart-o fa-3x'></i>".html_safe, vote_micropost_path(@micropost, type: "up"), :method => :post, :remote => true %>')
<% end %>
试一试
$(“#投票a”).html(“:post,:remote=>true%>”)
$(“#投票a”).html(“:post,:remote=>true%>”)
或使用
$("#vote<%= @micropost.id %> a").html('<%= link_to content_tag('i', class: 'fa fa-heart fa-3x'), vote_micropost_path(@micropost, type: "down"), :method => :post, :remote => true %>')
$(“#投票a”).html(':post,:remote=>true%>)
<% if current_user && @micropost.has_evaluation?(:votes, current_user) %>
$("#vote<%= @micropost.id %> a").html('<%= link_to "<i class=\"fa fa-heart fa-3x\"> </i>".html_safe, vote_micropost_path(@micropost, type: "down"), :method => :post, :remote => true %>')
<% else %>
$("#vote<%= @micropost.id %> a").html('<%= link_to "<i class=\"fa fa-heart-o fa-3x\"></i>".html_safe, vote_micropost_path(@micropost, type: "up"), :method => :post, :remote => true %>')
<% end %>
$("#vote<%= @micropost.id %> a").html('<%= link_to content_tag('i', class: 'fa fa-heart fa-3x'), vote_micropost_path(@micropost, type: "down"), :method => :post, :remote => true %>')