2016-07-15 224 views
0

我剛在Laravel的付款視圖中插入了引導摺疊。 Bootstrap在我點擊它時崩潰,但我希望它自動摺疊。Bootstrap摺疊不會自動摺疊

我知道我必須設置這樣:aria-expanded="false"

但它仍然沒有工作。也許是因爲它有這樣的自己的ID?

href="#collapse{{ $charity->id }}"

這裏是我完整的液晶面板片段:

@foreach($charities as $charity) 

    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> 
     <div class="panel panel-default"> 
      <div class="panel-heading" role="tab" id="headingOne"> 
       <h4 class="panel-title"> 
        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{{ $charity->id }}" aria-expanded="false" aria-controls="collapseOne"> 
         <div class="row"> 
          <div class="col-xs-3 col-sm-2 col-md-2"> 
           <img class="media-object" src="{{ $charity->photo }}" width="75px" height="65px" alt="{{ $charity->name }}"> 
          </div> 
          <div class="col-xs-9 col-sm-10 col-md-10"> 
           {{ $charity->name }} 
          </div> 
         </div> 
        </a> 
       </h4> 
      </div> 
      <div id="collapse{{ $charity->id }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne"> 
       <div class="panel-body"> 
        {{ $charity->description }} 
       </div> 
      </div> 
     </div> 
    </div> 

@endforeach 
+0

嘗試從'ID = 「崩潰{{$ charity-> ID}}」' –

回答

1

如果你想第一個面板上的頁面加載關閉,從中取出.in類。

從這 - ><div id="collapse{{ $charity->id }}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">

爲了這個 - ><div id="collapse{{ $charity->id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">

崩潰插件使用了幾類來處理繁重 提升:

  1. .collapse隱藏內容
  2. .collapse.in顯示內容
  3. 過渡開始時當它完成

參見Collapse Usage在文檔

  • .collapsing加入,併除去。

    例子:

    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> 
     
    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> 
     
        <div class="panel panel-default"> 
     
    
     
        <div class="panel-heading" role="tab" id="headingOne"> 
     
         <h4 class="panel-title"> 
     
         <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne"> 
     
          <div class="row"> 
     
          <div class="col-xs-3 col-sm-2 col-md-2"> 
     
           <img class="media-object" src="http://placehold.it/350x150" width="75px" height="65px" alt="alt"> 
     
          </div> 
     
          <div class="col-xs-9 col-sm-10 col-md-10"> 
     
           NAME 
     
          </div> 
     
          </div> 
     
         </a> 
     
         </h4> 
     
        </div> 
     
    
     
        <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> 
     
         <div class="panel-body"> 
     
         DESC 
     
         </div> 
     
        </div> 
     
    
     
        </div> 
     
    </div> 
     
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
     
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

  • +0

    是,工程移除坍塌類。謝謝! – David