jquery-ui手风琴:添加行而不破坏和重新创建? [英] jquery-ui accordion: adding rows without destroying and recreating?

查看:132
本文介绍了jquery-ui手风琴:添加行而不破坏和重新创建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jquery手风琴,我想添加行。我可以通过调用.accordion(destroy),添加所需的< h3>< / h3>< div> ...位然后调用来完成此操作.accordion()再次,但这会破坏状态并关闭所有打开的分隔符。

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.

是否可以在没有销毁的情况下向手风琴添加行并重新创建它? / p>

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

推荐答案

不,这是不可能的。 jQuery应该为手风琴添加添加方法,就像它们对标签一样:

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.

这篇关于jquery-ui手风琴:添加行而不破坏和重新创建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆