jQuery Accordion删除里面的项目

时间:2013-12-23 19:23:37

标签: jquery jquery-ui accordion

我遇到了JQUERY Accordion的以下问题。

当我删除一个项目时,手风琴会丢失其配置,好像jquery手风琴永远不会被应用一样。

Example:
//INITIALIZE THE ACCORDION.
$("#divAccordion1").accordion();

//REMOVE DIV ITEM INSIDE ACCORDION PANEL 1.
$("#div1").children('div').eq(0).remove();

//删除后>问题发生了。

<div id="divAccordion1">
    <h3 style="padding: 10px;padding-left: 25px; ">ACCORDION 1</h3>
    <div id="div1" style="background-color: #EEEEEE;">
        <div style="width: 80px; height:  80px; display: inline-block; margin:10px;">
            <img src="" />
        </div>
        <div style="display: inline-block;  margin-top: 10px;">
            some data 1
        </div>
        <div style="display: inline-block;  margin-top: 10px; margin-left: 50px;">
            some data 2
        </div>
    </div>

    <h3 style="padding: 10px;padding-left: 25px; ">ACCORDION 2</h3>
        <div id="div2" style="background-color: #EEEEEE;">
            <div style="width: 80px; height:  80px; display: inline-block; margin:10px;">
                <img src="" />
            </div>
            <div style="display: inline-block;  margin-top: 10px;">
                some data 1
            </div>
            <div style="display: inline-block;  margin-top: 10px; margin-left: 50px;">
                some data 2
            </div>
        </div>
    </div>

1 个答案:

答案 0 :(得分:1)

删除div后,您可能需要使用手风琴refresh()

$("#divAccordion1").accordion('refresh');