Bug Tracker

Opened 8 years ago

Closed 8 years ago

#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:
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.

Change History (1)

comment:1 Changed 8 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.