Search code examples
jqueryjquery-selectorsjquery-effects

FadeTo() on this selection (cloned and appended) not working?


I'm new to jQuery and i'd like to fadeTo() this selection to give user feedback about data being fetched from the server:

// Loop on each array of object returned from the ajax call
$.each(v, function(i, obj) {
   current.find('.key:first').parent()
      .clone(true).appendTo(current)
         .find('.key').text(obj.key).andSelf();
};

I've tryed (without success) adding fadeIn('slow', 1) call after appendTo(current).


Solution

  • From what I'm guessing, your content appears straight up and you wish it'd fade in.

    You need to hide the cloned element before appending to the "current" element. Try this :

    $.each(v, function(i, obj) {
       current.find('.key:first').parent()
          .clone(true).hide(1).appendTo(current).fadeIn('slow')
             .find('.key').text(obj.key).andSelf();
    };