Adding :class parameter to link_to_remote in Rails
Monday, November 27th, 2006Well, this is mostly a note to myself, since I have spend almost half an hour trying to figure how to add class parameter to a link generated by link_to_remote in Rails.
Well here is the code (with all bells and whilstles):
<%= link_to_remote "Vote on it",
{
:url => { :action => 'vote', :id => post_dig.id },
:update => 'thevote',
:before => visual_effect(:opacity, 'thevote', :duration => 0.2, :from => 1.0, :to => 0.1),
:complete => visual_effect(:opacity, 'thevote', :duration => 0.5, :from => 0.1, :to => 1.0)
},
:class => "vote"
%>
This code updates the contents of an element with id='thevote', and adds nice fade-out/in during the update. Most important that it also adds class "vote" to the generated link so it can be used for a nice CSS rollover.

