adding visual effects to RJS before action rendered
- by Sam
I just started using RJS which is awesome however I am used to putting visual effects in the link_to_remote and such and I'm not sure how to trigger actions before and after remotes are triggered.
Take this link for example:
HTML
<span id="<%= "edit_comment_link_#{comment.id.to_s}"%>" style="float:left;">
<%= link_to_remote "edit", {:update => "comment_#{comment.id.to_s}", :url => edit_post_comment_path(comment.post, comment), :method => :get}%> | </span>
Controller:
def edit
@comment = Comment.find(params[:id])
respond_to do |format|
#format.html render edit_comment_path(@comment)
format.js
end
end
RJS:
page.replace_html "edit_comment_link_#{@comment.id.to_s}", "currently editing | "
So is RJS mainly for after actions are rendered visual effects such as a spinner should be put into the link_to_remote with call_backs? Is this a good way of doing things?