【发布时间】:2012-08-20 05:34:02
【问题描述】:
我有一个很好的即时行高亮示例: http://www.mrc-productivity.com/techblog/?p=684
如何使用 rails 创建<a href="#" class="on">Turn on row highlights</a> 链接。
我尝试了许多 link_to 和 button_to 与 :remote => true 的组合,但我无法正确使用语法,而且一切似乎都以常规链接结束。
在一天结束时,我试图打开和关闭行表突出显示,如下所示:
html:
<a href="#" class="on">Turn on row highlights</a>
jquery:
$(document).ready(function() {
$("a.on").click(function(){
$("tr:nth-child(odd)").addClass("two");
$("tr:nth-child(even)").addClass("one");
event.preventDefault();
});
$("a.off").click(function(){
$("tr:nth-child(odd)").removeClass("two");
$("tr:nth-child(even)").removeClass("one");
});
});
【问题讨论】:
标签: ruby-on-rails ruby link-to