views:

82

answers:

2

I'm trying to get a jQuery UI Accordion, with initially all divs collapsed.

The doc says

  // getter
  var active = $('#div0').accordion('option', 'active');
  // setter
  $('#div0').accordion('option', 'active', -1);

Neither of these was working in v1.7.2. The getter always returned null, and the setter had no effect.

I found this bug: http://dev.jqueryui.com/ticket/4576 , which included a fix for the getter.

But the setter still doesn't work.

Anyone have a fix for the setter?

A: 

I'm not sure how to set arbitrary indexes as open, but...

I can create a create an accordion with nothing open, via:

$(document).ready(function() {
    $('#div0').accordion({collapsible:true, active:false});
});
Cheeso
+1  A: 

Did you try initializing the accordion with just the active option?

$('#div0').accordion({active: 1});

Or use the activate method. Checkout the docs - http://docs.jquery.com/UI/Accordion#method-activate

$('#div0').accordion('activate', 1);
Anurag