【问题标题】:accordion insideYii Clistview - not workingYii Clistview 内的手风琴 - 不工作
【发布时间】:2012-08-17 09:21:26
【问题描述】:

我在页面加载时使用 Yii 框架组件 CLISTVIEW,ajax 手风琴停止工作

我试过了,但是没用

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

});

当我将 on 表单加载中的事件类型更改为 click 时,它开始工作。在这里调用的正确事件类型是什么。

【问题讨论】:

  • 您能否从视图的其余部分添加更多代码,以便为问题提供更多上下文。它会让你更容易给你建议/解决方案

标签: jquery-ui jquery yii


【解决方案1】:

手风琴插件需要这种内容:

<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 .items 元素,然后根据手风琴插件的需要重写元素:

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

手风琴也能正常工作。

【讨论】:

    猜你喜欢
    • 2012-10-07
    • 2011-05-30
    • 2016-06-22
    • 1970-01-01
    • 2016-09-02
    • 2014-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多