[英]Rails js.erb file and append
我怎樣才能在js.erb中附加它
<%= @images.each do |f| %>
<div class="someclass"><%= image_tag(f.image) %>
<% end %>
這不起作用。 我也嘗試過escape_javascript ...
$('.gallery_container').append('
<% @images.each do |f| %>
<div class="someclass"><%= link_to image_tag(f.image), "#" %> </div>
<% end %>
')
試試這個
<% 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.