Skip to main content

Bug Tracker

Side navigation

#10742 closed bug (invalid)

Opened November 09, 2011 10:41PM UTC

Closed November 10, 2011 03:33AM UTC

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

Reported by: jas@rephunter.net 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.

Attachments (0)
Change History (1)

Changed November 10, 2011 03:33AM UTC by dmethvin comment:1

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.