Created
December 12, 2011 21:46
-
-
Save joshuacc/1469254 to your computer and use it in GitHub Desktop.
checkbox behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When the final report checkbox is clicked | |
$('table.detailed input[type="checkbox"].final-report').click(function() { | |
// Find the associated optional and midyear report checkboxes | |
var $opt_mid = $this.parents('table.detailed').children('input[type="checkbox"]').filter('.optional-report, .midyear-report'); | |
// If the final report checkbox is checked | |
if ( $(this).is(':checked') ) { | |
// For each optional/midyear checkbox | |
$opt_mid.each(function() { | |
// If it is not disabled | |
if ( $(this).is(':not(":disabled")') ) { | |
// Uncheck it and disable it | |
$(this).attr('disabled', 'disabled'); | |
} | |
}); | |
} else { | |
// For each optional/midyear checkbox | |
$opt_mid.each(function() { | |
// If it is NOT both checked and disabled | |
if ( $(this).is(':not(":checked"):not(":disabled")') ) { | |
// Re-enable it | |
$(this).removeAttr('disabled'); | |
} | |
}); | |
} | |
}); | |
// When the optional/midyear checkbox is clicked | |
$('table.detailed input[type="checkbox"]').filter('.optional-report, .midyear-report').click(function() { | |
// Find the associated final report checkbox | |
var $final_report = $(this).parents('table.detailed').children('input[type="checkbox"].final-report'); | |
// If the optional/midyear checkbox is checked | |
if ( $(this).is(':checked') ) { | |
// Uncheck and disable the final report checkbox | |
$final_report.removeAttr('checked').attr('disabled', 'disabled'); | |
} else { | |
// Enable the final report checkbox | |
$final_report.removeAttr('disabled'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment