开发者

Rails 3.0 jquery - fade-out old record, fade-in new record

开发者 https://www.devze.com 2023-03-14 19:00 出处:网络
the situation: I\'m using will-paginate to display a bunch of user profiles to a user, five profiles at a time. The user can choose to unlike any of the five user profiles being displayed by clicking

the situation: I'm using will-paginate to display a bunch of user profiles to a user, five profiles at a time. The user can choose to unlike any of the five user profiles being displayed by clicking on an unlike button which processes the code below. The code works and the profile fades-out. What I want is to replace this removed user profile div with the div of a new profile/record. I want the div of this new record to fade-in.

  $(".unlike_button").live("click", function() {
    var self = $(this);
    $.post("/user/unlike", {id: $(this).parent().attr("user-id"开发者_如何学C)}, function(data) {
      if (data) {
        self.parent().fadeOut();
      }
    });
  }) 

Any ideas how to achieve this? If you need more info to answer the question, please let me know. Thanks!


Modify the self.parent().fadeOut(); with a callback function to perform actions when the fadeOut has completed:

self.parent().fadeOut(function(){
$(this).html(data).fadeIn();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消