Cheeso
Cheeso

Reputation: 192487

jQuery: How to set the index of the current open div in jQuery UI accordion?

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?

Upvotes: 0

Views: 1638

Answers (2)

Anurag
Anurag

Reputation: 141879

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);

Upvotes: 2

Cheeso
Cheeso

Reputation: 192487

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});
});

Upvotes: 0

Related Questions