[jQuery] How to bind a function only once

2006-10-18 Thread Brian Litzinger
I have a group of checkboxes, and as long as any one of the boxes is checked I need a function bound to a select list, but anytime none of the boxes are checked I need the function unbound. What I have below binds and unbinds, but if I select lets say 4 checkboxes the function is bound and called

Re: [jQuery] How to bind a function only once

2006-10-18 Thread Dave Methvin
I have a group of checkboxes, and as long as any one of the boxes is checked I need a function bound to a select list, but anytime none of the boxes are checked I need the function unbound. What I have below binds and unbinds, but if I select lets say 4 checkboxes the function is bound and

Re: [jQuery] How to bind a function only once

2006-10-18 Thread John Resig
Hi Brian - Here is how I would change your code: $('[EMAIL PROTECTED]').click(function(){ $('#label').unbind('change'); if ( $([EMAIL PROTECTED]'label_checkbox']:checked).length ) $('#label').bind('change', function(){ alert('test'); }); }); By making it