Bug Tracker

Modify

Ticket #8144 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

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

comment:1 Changed 2 years ago by dmethvin

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

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.

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.