Modify ↓
Ticket #8144 (closed bug: invalid)
jQuery .fadeOut calls the callback routine immediately
| Reported by: | rwap | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I have a webpage which basically uses the code:
<script type="text/javascript">
function reloadPage()
{
location.reload();
}
$(function(){
$(".forceFade").fadeOut(5000, reloadPage());
});
</script>
The .forceFade class is added either when the page is loaded, or by some javascript as a timer reaches the end point.
Unfortunately, the above example reloads the page immediately (it does not wait the 5 seconds set).
If I change the call to
$(function(){
$(".forceFade").fadeOut(5000);
});
The chosen sections fade as would be expected, but the page does not reload.
I have tried v1.4.4 and v.1.4.3 - I cannot use v1.5 on my site due to other code I link in.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

You're calling the function immediately when you add the () to the end of it. Take off the parens and it will fire the callback as you intended. If you need more help on this, please ask on the forum.