Preventing/suppressing repeated animations on same select
Hi everyone,
I have some elements that hide and show real quick when I click on the same selected checkbox. I only want to hide or show something on change, and only when I need to. The way the behavior works now is I have 20 checkboxes, and each time I check one (even if it's the same), I see the associated elements hiding, then showing real quick. I don't want anything to happen though if all they do is toggle the checkbox, unless there's a condition to uncheck it. It's kind of hard to convey what I'm talking about here, but maybe my code can shed some light:
- if (obj.key == "2C41") {
// insert handler for 2C41
$('[name="'+obj.name+'"]:checkbox').live("click", function () {
if ($('[name="'+obj.name+'"]:checkbox:checked').length == 0) {
$.each(obj.eid, function () {
$('#'+this).toggleHide(true);
});
}
else {
aThroughS = $('[name="'+obj.name+'"]:checked:checkbox').q2C41(obj);
tOnly = $('[name="'+obj.name+'"]').q2A31(obj, 18);
rAndS = ($('[name="'+obj.name+'"]').q2A31(obj, 16) && !(tOnly));
aThroughST = (aThroughS && tOnly);
// A-S only selected
$('#_AdditionalInformation').toggleHide(!aThroughS);
$('#q3240id').parent().toggleHide(!tOnly);
$('#_OtherInfoTypes').toggleHide(!aThroughST);
$('#q3211id').toggleHide(rAndS);
}
});
}
- (function ($) {
$.fn.toggleHide = function (toggle) {
var $this = this;
//console.log(this);
if (toggle) $.each($this, function () { $(this).hide(); });
else $.each($this, function () { $(this).show(); });
}
})(jQuery);
TIA,
Eugene "Eggers"