jQuery colorbox-即使在关闭后也会被调用

jQuery colorbox-即使在关闭后也会被调用,jquery,colorbox,Jquery,Colorbox,我面临一个奇怪的问题。我确实需要在选中复选框时显示弹出窗口。它工作正常,但即使在取消选中时也会出现相同的弹出窗口 <af:objectImage id="agreementCheckBoxImg" source="/base/images/spacer.gif" styleClass="jqTransformCheckbox" onclick="displayPopup(this.id,'main\\\\:content\\\\:Popupregion\\\\:Popup','520px'

我面临一个奇怪的问题。我确实需要在选中复选框时显示弹出窗口。它工作正常,但即使在取消选中时也会出现相同的弹出窗口

<af:objectImage id="agreementCheckBoxImg" source="/base/images/spacer.gif" styleClass="jqTransformCheckbox" onclick="displayPopup(this.id,'main\\\\:content\\\\:Popupregion\\\\:Popup','520px','260px');return false;"/>

<script type="text/javascript">    
    function displayPopup(buttonId,popId,width,height) {
        var eminputSelf = $("#main\\:content\\:check");
        if (eminputSelf.attr("checked") == true) { // check box condition works fine
            alert('returning do not show popup');
        } else {
            $('#'+needHelpId).colorbox({ open:true, title:'',innerWidth:interWidth, innerHeight:innerHeight,close:'shutdown', inline:true, href:popId , onOpen:function(){ $(popId ).show();}, onCleanup:function(){ $(popId ).hide();}});
        }
    }

</script>

功能显示弹出窗口(按钮ID、popId、宽度、高度){
var eminputSelf=$(“#main\\:content\\:check”);
如果(eminputSelf.attr(“checked”)==true){//复选框条件正常工作
警报(“返回时不显示弹出窗口”);
}否则{
$('#'+needHelpId).colorbox({open:true,title:'',innerWidth:interWidth,innerHeight:innerHeight,close:'shutdown',inline:true,href:popId,onOpen:function(){$(popId).show();},onCleanup:function(){$(popId.hide();});
}
}
取消选中期间会出现警报,但弹出窗口也会出现

请帮忙。提前感谢。

尝试使用:

if (eminputSelf.prop("checked") === true) {
prop()

试试这个:

if (eminputSelf.is(":checked")) { // checked condition
  // existing code
} else {
  // existing code  
}

祝你好运

代码的其余部分在哪里?复选框事件侦听器?上面的
if/else
叫什么?如果有人想为您制作一个演示,HTML可能也很有用。这个条件工作正常,并且返回时不需要调用其他人。但是弹出窗口还是来了,我打电话给胡扯。显然,正在调用else条件,或者正在从脚本中的其他地方调用模态。此条件工作正常,返回时不调用else部分。但弹出窗口仍然出现。我已共享了代码,但无法共享,因为它使用的是自定义组件。@Vanathi,“needHelpId”此参数未在函数中传递。你怎么知道的?