Skip to main content

Bug Tracker

Side navigation

#8144 closed bug (invalid)

Opened February 02, 2011 03:07PM UTC

Closed February 02, 2011 03:26PM UTC

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

Attachments (0)
Change History (1)

Changed February 02, 2011 03:26PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

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.