Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript js.erb文件中链接到帮助器的嵌套引号_Javascript_Ruby On Rails_Ajax - Fatal编程技术网

Javascript 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_

我试图在我用于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_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 %>')