将项目添加到一个jQuery手风琴与jQuery [英] Add items to a jQuery Accordion with jquery

查看:107
本文介绍了将项目添加到一个jQuery手风琴与jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery的手风琴插件做一些数据的手风琴。然后,我希望用户能够添加更多的数据的手风琴。我已经安装了手风琴正常工作,然后我做了一个函数,prepends一个列表项,以匹配手风琴语义手风琴。

I am using the jQuery accordion plugin to make an accordion of some data. Then I want the user to be able to add more data to the accordian. I have setup the accordion to function properly, then I've made a function that prepends a "list item" to the accordion that matches the accordion semantics.

是否可以更新手风琴,使其与新添加的元素的作品,如果没有新的数据保存到数据库,并刷新页面?

Is it possible to "update" the accordion so that it works with the newly added element, without saving the new data to database and refreshing the page?

事情是这样的:

.accordion('refresh')

或者类似的东西在jQuery的1.3增加了现场活动,任何人都得到了线索?

Or something like the live event added in jQuery 1.3, anybody got a clue?

推荐答案

我没有测试过,但是,这个可能应该工作: 你说,你有你的手风琴ID #accordion

I haven't tested it, but this should probably work: Say that you have your accordion with id #accordion

$('#accordion').append('<h3><a href="#">New Paragraph</a></h3><div><p>New data</p></div>')
    .accordion('destroy').accordion();

基本上,只要破坏并重新创建手风琴。

Basically, just destroy and re-create the accordion.

更新:

由于这个答案是写一个刷新()方法被添加到折叠菜单。它可以通过调用来调用:

Since this answer was written a refresh() method has been added to the accordion widget. It can be invoked by calling:

$( ".selector" ).accordion( "refresh" );

您可以阅读更多有关此方法 href="http://api.jqueryui.com/accordion/#method-refresh">

You can read more about this method here

这篇关于将项目添加到一个jQuery手风琴与jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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