views:

539

answers:

1

I've got the accordion working fine on pageload, however upon user interaction with some elements on the page, I am using ajax to rebuild the HTML of the accordion. Then, I try to re-initialize the accordion again with

    $('#accordion').accordion({
  active: false,
  autoHeight: false,
  clearStyle: true,
  collapsible: true,
  header: 'h3'
 });

but... it doesn't seem to be taking.

The new block of rendered HTML isn't applying the accordion rules. Instead it just stays open as a large list.

I've even tried setTimeout() for re-calling the accordion just incase it was trying to initialize before the rendered HTML is returned in the callback.

The HTML that is rendered in the callback is the exact same as that of the pageload (with exception to the DOM additions that occur when the Accordion method is effective)

+1  A: 

Destroy the accordian before repopulating it with data.

$('#accordion').accordion('destroy');
Stefan Kendall
thanks, that fixed it. I really appreciate it.
aimlessWonderer
No problem. I had the exact same problem with the dialog UI component, and the fix was the same. You have to explicitly destroy everything (for now) in jquery-ui to get components to a good state. This should be documented somewhere!
Stefan Kendall