0

我想内联添加这个 html 数据标签

data-zoom-image="<% image_tag(step.i_connection.image.image.url(:large) %>"

到这个 erb 标签,但我不确定我会怎么做。有任何想法吗?

<%= image_tag(step.i_connection.image.image.url(:medium), id: "iconnection#{n}") %>
4

1 回答 1

3

您将其传递给 likedata: { zoom_image: "large/image1.jpg" }并且 data 属性将转换为data-zoom-image="large/image1.jpg".

尝试:

<%= image_tag(step.i_connection.image.image.url(:medium), id: "iconnection#{n}", data: { zoom_image: "large/image1.jpg" }) %>

更新:

我认为您想输出结果:
<% image_tag(step.i_connection.image.image.url(:large)) %>而不仅仅是解释它。

尝试:

data: { zoom_image: "#{ image_tag(step.i_connection.image.image.url(:large)) }" }
于 2013-08-15T01:30:48.080 回答