tags:

views:

48

answers:

2

I am loading in html via AJAX and appending it to a DIV but I want to be able to select the newly loaded in html and apply a hide().fadeIn() to elements in that newly appended html.

Current function looks something like this

wall = new Object();

wall.showWall = function (options) {
    // Use this to initiate the comment wall
 $.ajax({
  url: "activity_results.html?"+options,
  cache: false,
  success: function(html){
      $("#comments .loader").hide(); // The wall's comment spinner
      requestStuff.showResponse(); // Trigger the addComment function
   if (!options){ // Make sure we are not paging
    wall.showMore();
   }
   $("#comments").append(html).hide().fadeIn("slow");
  }
 });

}

When new html gets loaded into #comments I want to be able to only fade in those nodes.

A: 

Instead of appending to #comments create a hidden div inside of it and append it to that div.

Then fadeIn that hidden div.

psychotik
+2  A: 
$(html).appendTo("#comments").hide().fadeIn("slow");
ChaosPandion
I didn't know you could pass html content as a selector to $... really?
psychotik
Unfortunately the effect does not get applied like this, it just appends and displays immediately.
Simon