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)
Destroy the accordian before repopulating it with data.
$('#accordion').accordion('destroy');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With