2012-09-13 42 views
0

我正面臨一個奇怪的問題。檢查複選框時,我確實需要顯示一個彈出窗口。它工作正常,但即使在取消選中時也會出現相同的彈出窗口。jQuery colorbox - 即使在關閉後也會調用

<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> 

在取消選中期間警報即將到來,但彈出窗口也會到來。

請幫忙。提前致謝。

+0

代碼的其餘部分在哪裏?複選框事件偵聽器?什麼叫上面的「if/else」?如果有人想爲你製作演示版,HTML也可能會有所幫助。 – Sparky

回答

1

嘗試使用:

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

prop()返回布爾值,並與複選框狀態變化,而attr()沒有。

http://api.jquery.com/prop/

+0

這個條件工作正常,並且沒有調用else就返回。但仍然彈出來。 – Vaandu

+0

我打電話給那個。顯然你的其他條件正在被調用,或者你正在腳本中的其他地方調用模態。 – Jack

0

試試這個:

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

GOOD LUCK !!

+0

這個條件工作正常,並且返回時不調用else部分。但仍然彈出來。 – Vaandu

+2

@Vanathi,分享整個代碼塊。 –

+0

我已經共享代碼,但無法共享,因爲它使用自定義組件。 – Vaandu

相關問題