私は素晴らしい RJS を使い始めたばかりですが、link_to_remote などに視覚効果を入れることに慣れていて、リモートがトリガーされる前後にアクションをトリガーする方法がわかりません。
たとえば、次のリンクをご覧ください。
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>
コントローラ:
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 | "
では、RJS は主に、アクションがレンダリングされた後、スピナーなどの視覚効果を link_to_remote に配置するためのものcall_backs
ですか? これは物事を行う良い方法ですか?