#1067 closed bug (fixed)
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
Change History (3)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
Nevertheless, at the very minimum this behavior should be documented.
comment:3 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I've updated the documentation to clarify this point: http://docs.jquery.com/Effects
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.