Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQUERY UI Accordion Resize on Window Resize?

I'm using the JQUERY UI Accordion module:

<script type="text/javascript">
$(function() {
    $("#sidebar_column_accordion").accordion({
        fillSpace: true,
        icons: { 'header': 'ui-icon-plus', 'headerSelected': 'ui-icon-minus' }
    });
});
</script>

By using the fillSpace option, the accordion takes up the entire height of the window which I want. Problem is it calculate the height on page load, and if the user resizes their browser, it does not adjust...

Is there a way to have the accordion recalculate the height/size when the browser window is resized?

Thanks

like image 602
AnApprentice Avatar asked Mar 11 '10 16:03

AnApprentice


1 Answers

$(window).resize(function(){
    $("#sidebar_column_accordion").accordion("resize");
});

In jQuery UI 1.9 the resize method was removed. The refresh method was added which is more robust and will work in this case also.

$(window).resize(function(){
    $("#sidebar_column_accordion").accordion("refresh");
});
like image 136
PetersenDidIt Avatar answered Sep 29 '22 04:09

PetersenDidIt