Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a jquery accordion which I want to add rows to. I can accomplish this by calling .accordion("destroy"), adding the needed <h3></h3><div>... bit and then calling .accordion() again, but this destroys the state and closes any dividers which are open.

Is it possible to add rows to the accordion without destroy and recreating it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
463 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...