2012-08-17 62 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> 

手风琴会正常工作。