为什么我不能根据复选框状态取消绑定事件?

时间:2011-12-28 17:21:01

标签: jquery events checkbox triggers

我正在尝试将事件监听器附加到复选框,只有当未选中时。 但即使我试图检查它,事件(发射叠加)也会发生。

  1. 转到此页面:http://eetest.netmagicsolutions.com/leadform/

  2. 从下拉列表中选择主机选项

  3. 尝试点击专用主机复选框

  4. 即使取消选中该复选框,您也会看到叠加层触发。

    这是我的代码:

    $grpBoxes.fireReveal = function($input) {       
    
        //fire overlay only if input is not checked
        $input.on('change.overlay', function(e) {
            console.log($input.attr('checked'));
            if($input.is(':checked')) {                 
                $input.overlay({
    
                onBeforeLoad: function(){                       
                    console.log('ready to fire');
                    $input.addClass('fired');                           
                },
    
                // load it immediately after the construction
                load:true,
    
                // disable this for modal dialog-type of overlays
                closeOnClick: false
    
                });                     
            }
    
            else {
                $input.removeClass('fired');
                $input.off('change.overlay');
                console.log($input.attr('checked'));
                return false;       
            }   
    
        }); // end callback
    
    
    
    
    }; // end fireReveal
    

    这是我的实时代码:http://eetest.netmagicsolutions.com/leadform/ 这是我的完整脚本:http://eetest.netmagicsolutions.com/leadform/js/jquery.leadform.js

    我做错了什么?

0 个答案:

没有答案