我有一个 Ruby on Rails 应用程序,我在其中跟踪对各种主题的喜欢或不喜欢。当用户点击喜欢时,喜欢的数量会增加,并且通过 ajax 调用立即显示数量以重新加载部分。但问题是由于link_to在我的一个控制器中调用了一个函数,然后执行ajax(在respond_to中),实际上没有任何内容存储在历史记录中,因此链接无法在访问时改变颜色。
这是我的CSS:
/* Links */
a:link {
color: #06c;
text-decoration: none;
}
a:visited {
color: red !important;
text-decoration: none;
}
a:hover{
color:#D8CA92;
text-decoration: none;
}
a:active {
color: #CC9966;
text-decoration: none;
}
我的链接:
<%= link_to '▲'.html_safe,{ :controller => :confessions, :action => :upvote, :id => conf.id }, :remote=>true %>
以及被调用的相关 js.erb 文件
$('#ajax').html("<%= escape_javascript(render :partial => 'layouts/confessions') %>");
如何在仍然使用 ajax 调用的同时让 a:visited 工作?