Bug Tracker

Opened 8 years ago

Closed 8 years ago

#10742 closed bug (invalid)

is(:visible) always returns true when toggle('fast') is used

Reported by: jas@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:

Description

I am new to jquery and am working with some pretty simple stuff. So this issue may be something that is a "feature" rather than a bug.

Here is the code:

	$('.accordion-hide').click(function(){
		$('.accordion').toggle('fast');
		if ($('.accordion').is(':visible')){
			alert('hide');
			$('.accordion-prompt').html('Hide this Help');
		}
		else
		{
			alert('show');
			$('.accordion-prompt').html('Show Help for this Page');
		}
	});

The problem is that the "true" branch of the if-statement is always taken when 'fast' is present as an argument to toggle. Removing 'fast' and the change of the text works as expected. But with 'fast' present, the true branch is always taken, as shown by the alerts.

Change History (1)

comment:1 Changed 8 years ago by dmethvin

Resolution: invalid
Status: newclosed

The .toggle("fast") happens asynchronously. Since it hasn't finished yet the code below it still sees the element as visible.

Please ask for help on the forum before opening a bug ticket, to be sure it is a bug. Also, we need complete test cases on jsFiddle.net rather than snippets of code within the ticket...we can't run those.

Note: See TracTickets for help on using tickets.