Skip to content
Permalink
Browse files

Accordion: Handle negative values for active option on init.

  • Loading branch information...
scottgonzalez committed Feb 3, 2011
1 parent 714a77f commit d099e3a3b2645ed1c6b0da8a654553970be7140c
Showing with 7 additions and 4 deletions.
  1. +3 −4 tests/unit/accordion/accordion_options.js
  2. +4 −0 ui/jquery.ui.accordion.js
@@ -51,12 +51,11 @@ test( "{ active: Number }", function() {

if ( $.uiBackCompat === false ) {
test( "{ active: -Number }", function() {
// TODO: fix initializing with negative value
var ac = $( "#list1" ).accordion({
// active: -1
active: -1
});
// equals( ac.accordion( "option", "active" ), 2 );
// state( ac, 0, 0, 1 );
equals( ac.accordion( "option", "active" ), 2 );
state( ac, 0, 0, 1 );

ac.accordion( "option", "active", -2 );
equals( ac.accordion( "option", "active" ), 1 );
@@ -48,6 +48,10 @@ $.widget( "ui.accordion", {
if ( !options.collapsible && options.active === false ) {
options.active = 0;
}
// handle negative values
if ( options.active < 0 ) {
options.active += this.headers.length;
}
self.active = self._findActive( options.active )
.addClass( "ui-state-default ui-state-active" )
.toggleClass( "ui-corner-all" )

0 comments on commit d099e3a

Please sign in to comment.
You can’t perform that action at this time.