[英]Rails js.erb file and append
How can I append this in js.erb 我怎样才能在js.erb中附加它
<%= @images.each do |f| %>
<div class="someclass"><%= image_tag(f.image) %>
<% end %>
This doesn't work. 这不起作用。 I have also tried with escape_javascript... 我也尝试过escape_javascript ...
$('.gallery_container').append('
<% @images.each do |f| %>
<div class="someclass"><%= link_to image_tag(f.image), "#" %> </div>
<% end %>
')
Try this 试试这个
<% str = "" %>
<% @images.each do |f| %>
str += '<div class="someclass">' + '<%= link_to image_tag(f.image), "#" %>' + '</div>'
<% end %>
$('.gallery_container').append(str.html_safe)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.