真的,我在构建正确的html时失去了一整天,渲染为js,
<tr>
<td><%= c.club_name.capitalize %></td>
<td><%= c.full_address %></td>
<td>
<%= link_to player_path(c), :"data-no-turbolink" => true, target: "_blank" do %>
<span class="glyphicon glyphicon-play-circle"></span>
<% end %>
</td>
<td>
<%= link_to edit_club_path(c) do %>
<span class="glyphicon glyphicon-pencil"></span>
<% end %>
</td>
<td>
<%= link_to c, method: :delete, data: { confirm: 'Are you sure?' } do %>
<span class="glyphicon glyphicon-trash glyphicon-red"></span>
<% end %>
</td>
</tr>
并且以html呈现的show.js.erb的内容为:
var name = <%= @club.club_name.capitalize %>;
var addr = <%= @club.full_address %>;
var link_player = <%= link_to player_path(@club), :"data-no-turbolink" => true, target: "_blank" do %>
'<span class="glyphicon glyphicon-play-circle"> </span>'.html_safe
<% end %>
var link_edit = <%= link_to edit_club_path(@club) do %>
'<span class="glyphicon glyphicon-pencil"></span>'.html_safe
<% end %>
var link_delete = <%= link_to @club, method: :delete, data: { confirm: 'Are you sure?' } do %>
'<span class="glyphicon glyphicon-trash glyphicon-red"></span>'.html_safe
<% end %>
$('#club_add').modal_success();
<% flash[:notice] = "Club created successfully" %>
var out_data = $.parseHTML("<tr><td>"+name+"</td><td>"+addr+"</td><td>"+link_player+"</td><td>"+link_edit+"</td><td>"+link_delete+"</td></tr>");
$('#clubs_table_tbody').prepend(out_data);
我收到js语法错误,如何构建第一个代码或字符串作为在浏览器中呈现的正确html?