Accordion append/refresh demo

Even though no panels are active, appending and refreshing causes the newly added panel to expand.

HTML

<link href="http://code.jquery.com/ui/jquery-ui-git.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-git.js"></script>
<script src="http://code.jquery.com/ui/jquery-ui-git.js"></script>

<div id="accordion">
   
</div>
<button id="clickme">Add new section</button>

JavaScript

$("#accordion").accordion({
    active: 'none'
});

$('#clickme').button().click(function () {
    $('#accordion').append('<h3>A new section</h3>');
    $('#accordion').append('<div>New section content</div>');
    $('#accordion').accordion('refresh');
});