Opened 8 years ago

Closed 4 years ago

#4672 closed feature (fixed)

Accordion: ability to add/remove panels

Reported by: wichert Owned by:
Priority: major Milestone: 1.10.0
Component: ui.accordion Version: 1.8
Keywords: Cc:
Blocked by: Blocking:

Description

It would be practical to be able to add items to an accordion. Currently you have to destroy and recreate the accordion, which is not very convenient.

Change History (9)

comment:1 Changed 8 years ago by scottgonzalez

  • Milestone changed from TBD to 1.8

We should look into how this is currently handled in other plugins, like tabs, and how it could be handled in any other plugins where adding/removing items would be useful.

comment:2 follow-up: Changed 7 years ago by mrfr0g

I needed this functionality for a project I'm working on, so I extended the base widget. I'm sure that this could be done more efficiently/better, but it works for my purposes.

New Method: add(el)
Parameter Type: jQuery object, or HTML Collection
New Option: autoActivate - Boolean - Set to true to auto activate the newly added node

http://www.e-d20.com/jquery/ui/jquery.ui.accordion.custom.js

Requirements: jquery-1.4.2, jquery-ui-1.8.2

Installation: Include the jquery.ui.accordion.custom.js in your page, after you have included jquery.ui.

Usage:

$("#accordion").accordion({

autoActivate: true

}) .accordion("add", $("<h3>New Node</h3><div><p>Content</p></div>"));

comment:3 Changed 7 years ago by scottgonzalez

  • Milestone changed from 1.9 to 1.next
  • Summary changed from Adding items to an accordion to Accordion: ability to add/remove panels
  • Type changed from enhancement to feature

comment:4 Changed 7 years ago by jzaefferer

Add a refresh-method, similar to menu (unlike tabs, thats fine).

comment:5 Changed 6 years ago by scottgonzalez

  • Status changed from new to open

comment:6 in reply to: ↑ 2 Changed 6 years ago by TheDoci

@scott.gonzalez Unfortunately this code is a little buggy when we use sortable accordions :

  1. First, the added accordion is always placed at bottom of the existing accordions.
  2. Then, after some sortings in the accordion's list, it bugs : it selects 2 or more accordions when sorting them, and we cannot place an element on top.

You can find a demo here : http://jsfiddle.net/a6rCu/

Last edited 6 years ago by TheDoci (previous) (diff)

comment:7 Changed 4 years ago by scottgonzalez

  • Milestone changed from 1.next to 1.10.0
  • Version set to 1.8

comment:9 Changed 4 years ago by David Petersen

  • Resolution set to fixed
  • Status changed from open to closed

Accordion: Enhance refresh to allow adding/removing panels. Fixes #4672 - Accordion: ability to add/remove panels

Changeset: d657538ed57a96b610853d69e9fbf559c5ae230f

Note: See TracTickets for help on using tickets.