Skip to main content

Bug Tracker

Side navigation

#1067 closed bug (fixed)

Opened March 24, 2007 10:18PM UTC

Closed April 05, 2007 02:29AM UTC

Last modified June 21, 2007 04:54AM UTC

fade callback triggered once for every element faded

Reported by: tabacco Owned by:
Priority: minor Milestone: 1.1.3
Component: effects Version: 1.1.2
Keywords: Cc:
Blocked by: Blocking:
Description

I'm not 100% certain this is a bug (as opposed to by design), but just in case...

It looks like calling one of the fade functions (fadeOut/fadeIn/fadeTo) on a selector that matches multiple objects in the code will cause the callback function to be fired once per object matched, instead of once.

For example...

<script type="text/javascript">
$(document).ready(function() {
     $(".some_class").fadeOut("normal", function() { 
          alert("hey!");
     });
}
</script>
<table>
<tr>
<td class="some_class">...</td>
<td class="some_class">...</td>
<td class="some_class">...</td>
</tr>
</table>

This will cause three "Hey!" alerts to happen. This becomes problematic when you want to fade out several divs (or whatever), populate them from an ajax request, and then fade them back in. Having the ajax request inside the callback means that three requests get made.

this

Attachments (0)
Change History (3)

Changed March 25, 2007 12:42PM UTC by joern comment:1

There are other cases where you need the callback for each element. The situation you describe could be solved by fading out a parent element, replacing its content via AJAX an fading it back in.

Changed March 30, 2007 03:56AM UTC by tabacco comment:2

Nevertheless, at the very minimum this behavior should be documented.

Changed April 05, 2007 02:29AM UTC by john comment:3

resolution: → fixed
status: newclosed

I've updated the documentation to clarify this point:

http://docs.jquery.com/Effects