How to :update after :success with link_to_remote Rails method?

Posted by Kevin on Stack Overflow See other posts from Stack Overflow or by Kevin
Published on 2010-05-08T17:48:51Z Indexed on 2010/05/08 17:58 UTC
Read the original article Hit count: 268

Hi,

I'm trying to get two things done after a user clicks on a link:

  1. Delete a div
  2. Add another element at the bottom of the page

I played with Rails link_to_remote and what I get with the code below is that the element is added before the div is deleted:

<%= link_to_remote "&#x2713;",
  :url => {
    :controller => :movies,
    :action => :mark_as_seen,
    :movie => movie,
    :render => 'movie' },
  :success => "Effect.Fade('movie_#{movie.id}_wrapper', { duration: 0.4 })",
  :update => "movies", :position => "bottom",
  :failure => "alert('Ooops! An error occurred.')"
%>

I tried to put :update and :position in a :complete callback, but nothing happened. And when I put both of them in the :success callback (after Effect.Fade), all I get is a parsing error.

Any idea?

Thanks,

Kevin

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about prototype