2013-07-10 72 views
0

有這個問題,讓我難以置信。我在手風琴組裏面有一個複選框。我的程序是當按下手風琴組內的複選框時,它將展開手風琴組的主體,並在另一個其他位置按下另一個按鈕。Bootstrap手風琴可摺疊和複選框更改干擾

問題是當按下兩個複選框時,按鈕顯示和隱藏真的很快。我的假設是點擊事件泡沫的地方,我無法抓住它,並關閉它的好!

我的HTML

<div class="accordion span5" id="info-accordion"> 
    <div class="accordion-group" data-pid="71" data-pweight="2"> 
     <div class="accordion-heading"> 
      <input type="checkbox" class="tier-check" value="17"> 
      <a class="accordion-toggle" data-toggle="collapse" href="#collapse-17">2013-07-10 14:21:03</a> 
     </div> 
     <div id="collapse-17" class="accordion-body in collapse" style="height: auto;"> 
      <div class="accordion-inner">Naware is a village in the Bassar Prefecture in the Kara Region of north-western Togo. and add some more content. This is the old one. should show in the info now. To be save really. 

      This text should be improved. 
      </div> 
     </div> 
    </div> 
    <div class="accordion-group" data-pid="71" data-pweight="2"> 
     <div class="accordion-heading"> 
      <input type="checkbox" class="tier-check" value="21"> 
       <a class="accordion-toggle" data-toggle="collapse" href="#collapse-21">2013-07-10 14:20:39</a> 
     </div> 
     <div id="collapse-21" class="accordion-body in collapse" style="height: auto;"> 
      <div class="accordion-inner">Naware is a village in the Bassar Prefecture in the Kara Region of north-western Togo. and add some more content. This is the old one. should show in the info now. To be save really. 

      This text should be improved. 


      This is new text 
      </div> 
     </div> 
    </div> 
    <div class="accordion-group" data-pid="71" data-pweight="2"> 
     <div class="accordion-heading"> 
      <input type="checkbox" class="tier-check" value="18"> 
      <a class="accordion-toggle" data-toggle="collapse" href="#collapse-18">2013-07-10 14:07:53</a> 
     </div> 
     <div id="collapse-18" class="accordion-body in collapse" style="height: auto;"> 
      <div class="accordion-inner">Naware is no more 
      </div> 
     </div> 
    </div> 
</div> 

,我的JavaScript是

//hide them all 
var orgchk = $('.tier-check:checkbox').not(':checked'); 

orgchk.each(function(i) { 
    $(this).removeAttr('disabled'); 

    var cllps = $('#collapse-' + $(this).val()); 
    if (cllps.hasClass('in')); 
      cllps.collapse('toggle'); 
}); 

//when only one checkbox is selected, show it 
var chkbx = $('.tier-check:checkbox:checked'); 
$('#collapse-' + chkbx.val()).collapse('show'); 

if (chkbx.length != 0) 
     $tier_btn.fadeIn(); 
else 
     $tier_btn.fadeOut(); 

這裏是一個小提琴http://jsfiddle.net/nuE2c/還是剪裁它朝我的情況

+0

您可以創建的jsfiddle證明問題的工作? – Schmalzy

回答

0

我找到了解決方案通過使用此。這似乎停止事件傳播時的jQuery stopPropogation()和StopImmediatePropagation()並沒有爲我

$('#accordion').on('hidden',function(e) { 
      return false;//stopping propagation 
    });