[jQuery] How to bind a function only once

[jQuery] How to bind a function only once


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 4
times when I change my select list. How do I just bind it once?
$('input[@name=label_checkbox]').click(function(){
        if($("input[@name='label_checkbox']").is(":checked")) {
            $('#label').bind('change', function(){
                alert('test');                            
            });
        } else {
            $('#label').unbind('change');
        }
    });
--
View this message in context: http://www.nabble.com/How-to-bind-a-function-only-once-tf2466835.html#a6876978
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/