jquery-ui accordion: adding rows without destroying and recreating?

后端 未结 1 1610
野的像风
野的像风 2020-12-19 20:14

I have a jquery accordion which I want to add rows to. I can accomplish this by calling .accordion(\"destroy\"), adding the needed

相关标签:
1条回答
  • 2020-12-19 20:47

    No it is not possible. jQuery should add an "add" method to accordion like they have for tabs:

    //save state
    var state = $("#accordion").accordion( "option", "active" );
    //add accordion item, destroy then re-create
    $("#accordion").append("<h3></h3><div/>").accordion("destroy").accordion();
    //set state
    $("#accordion").accordion( "option", "active", state );
    

    Wrap it in a nice method, extend accordion, submit a patch, etc. I didn't test this but it should work. You might have to adjust the state value if the tab was inserted before the active accordion item, instead of appended to the end.

    0 讨论(0)
提交回复
热议问题