adding visual effects to RJS before action rendered

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-05-08T03:47:57Z Indexed on 2010/05/26 19:11 UTC
Read the original article Hit count: 316

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rjs