表列的变化内容给定一个带有表的简单视图:Rails3中:鼠标悬停
<% entries.each do |entry| %>
<tr>
<td class="align-left"><%= entry.date.strftime("%d.%m.%Y") %></td>
<td class="align-right><%= my_number_to_currency entry.amount_calc %></td>
<td class="align-left"><%= entry.description %></td>
<td class="align-left"><%= entry.tag %></td>
</tr>
<% end %>
我想改变第二列的内容(每个条目),以my_number_to_currency在运行时entry.amount上鼠标悬停并在鼠标再次离开时变回原始值。另外,我想添加另一种样式,可以是class =“over”,也可以直接设置元素的颜色。
我很感谢任何指针如何在Rails3中实现最佳效果(以及如何在只需要一个视图的情况下放置代码的位置)。
(备注:my_number_to_currency是一个简单的辅助,只是觉得正常number_to_currency和我加入了jQuery的标签,因为我已经使用这个自动完成,因此它可如果有帮助的解决方案)
UPDATE
我试过的application.js成功如下:
$(document).ready(function() {
$(".joint").hover(
function() { $(this).children(".full").show(); $(this).children(".half").hide(); },
function() { $(this).children(".half").show(); $(this).children(".full").hide(); }
);
});