2012-08-17 61 views
1

I M採用與AJAX手風琴停止工作手風琴insideYii CListView中 - 不工作

我曾試圖後續頁面加載Yii框架組件CListView中,但沒有奏效

$(".items").on('load',function(){ 
$(this).accordion(); 

});

,當我在形式負載變化的事件類型中點擊它開始工作。什麼是正確的事件類型在這裏打電話。

+0

您能否從視圖的其餘部分添加更多的代碼,以便問題有更多的上下文。它會讓你更容易給你建議/解決方案 – 2012-08-17 15:50:34

回答

0

手風琴插件預計這樣的內容:

<h3>Section 1</h3> 
<div> 
    <p>Content section 1</p> 
</div> 
<h3>Section 2</h3> 
<div> 
    <p>Content section 2</p> 
</div> 

但是,如果我理解你的處境,你有這樣的代碼:

<body> 
    <div class="items"> 
     <h3>Section 1</h3> 
     <div> 
      <p>Content section 1</p> 
     </div> 
    </div> 
    <div class="items"> 
     <h3>Section 2</h3> 
     <div> 
      <p>Content section 2</p> 
     </div> 
    </div> 
</body> 

有了這個腳本冷杉我.wrapAll。項目元素,然後我重寫元素作爲手風琴插件想要的:

<script> 
     $(function() { 
      $('.items').wrapAll($('<div>').attr('id','accordion')); 
      $.each($('.items'),function(){ 
       $(this).remove(); 
       $('#accordion').append($(this).html()); 
      }); 
      $('#accordion').accordion(); 
     }); 
    </script> 

HTML將:

<div id="accordion"> 
    <h3>Section 1</h3> 
    <div> 
     <p>Content section 1</p> 
    </div> 
    <h3>Section 2</h3> 
    <div> 
     <p>Content section 2</p> 
    </div> 
</div> 

手風琴會正常工作。