Side navigation
#8488 closed bug (fixed)
Opened March 09, 2011 10:02PM UTC
Closed March 10, 2011 03:05AM UTC
Last modified March 14, 2012 06:21PM UTC
.toggle( showOrHide ) is not consistent with documentation
| Reported by: | kellyselden | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | 1.next |
| Component: | unfiled | Version: | 1.5.1 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
the documentation says it is the equivalent to
if (showOrHide) {
$('#foo').show();
} else {
$('#foo').hide();
}
but if showOrHide = 1, toggle will not show it because it is checking for a boolean type at line 7498 in jquery 1.5.1
toggle: function( fn, fn2, callback ) {
var bool = typeof fn === "boolean";
my simplified code looks something like this when i ran into the problem:
function toggleSection(show) {
//bunch of stuff based on show
$('.something1').toggle(show);
}
toggleSection($('.something2:checked').length);
my work-around is to always remember to check against true
$('.something1').toggle(show == true);
Attachments (0)
Change History (1)
Changed March 10, 2011 03:05AM UTC by comment:1
| resolution: | → fixed |
|---|---|
| status: | new → closed |
I've updated the docs to clarify the equivalent code to emphasize that it needs a
Booleanargument or it won't match that particular API signature.