Bug Tracker

Modify

Ticket #1067 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

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:
Blocking: Blocked by:

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

Change History

comment:1 Changed 6 years ago by joern

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.

comment:2 Changed 6 years ago by tabacco

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

comment:3 Changed 6 years ago by john

  • Status changed from new to closed
  • Resolution set to fixed

I've updated the documentation to clarify this point:  http://docs.jquery.com/Effects

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.