Ruby on rails 3.2 无法在index.html.erb文件中单击图像
如何使图像在rails视图页面中可点击。我在index.html.erb文件中尝试过,但仍然没有出现 下面是我写的代码Ruby on rails 3.2 无法在index.html.erb文件中单击图像,ruby-on-rails-3.2,Ruby On Rails 3.2,如何使图像在rails视图页面中可点击。我在index.html.erb文件中尝试过,但仍然没有出现 下面是我写的代码 <tbody> <% @messages.each do |t| %> <tr> <td><%= t.from %></td> <td><%= t.subject %></td> <td id ="message
<tbody>
<% @messages.each do |t| %>
<tr>
<td><%= t.from %></td>
<td><%= t.subject %></td>
<td id ="message"><%= image_tag("note.gif")%></td>
<script type="javascript">
jQuery("#message").click(function() { jQuery("#message").html("<%=t.message%>") });
</script>
<td><%=t.created_at.strftime("%b %d, %Y")%></td>
<td><%= link_to 'Destroy', t, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
jQuery(“#消息”)。单击(函数(){jQuery(#消息”).html(“”});
尝试以下操作:
<tbody>
<% @messages.each do |t| %>
<tr>
<td><%= t.from %></td>
<td><%= t.subject %></td>
<td><%= link_to image_tag("note.gif"), path_to_desired_page %></td>
<td><%= t.created_at.strftime("%b %d, %Y") %></td>
<td><%= link_to 'Destroy', t, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
将
指向所需页面的路径
替换为您希望将图像链接到的任何页面。谢谢您的回答,但我希望在单击图像后,它显示已存在于@message中的t.message。