@@ -564,7 +564,6 @@ var privates = {
564564 wizard . bind ( "keyup.steps" , privates . keyUpHandler ) ;
565565 }
566566
567- wizard . find ( ".steps a" ) . bind ( "click.steps" , privates . stepClickHandler ) ; // TODO: Try to move this code line to renderTitle
568567 wizard . find ( ".actions a" ) . bind ( "click.steps" , privates . paginationClickHandler ) ;
569568 } ,
570569
@@ -588,11 +587,14 @@ var privates = {
588587 // Create a content wrapper and copy HTML from the intial wizard structure
589588 var contentWrapper = $ ( document . createElement ( options . contentContainerTag ) )
590589 . addClass ( "content" ) . html ( wizard . html ( ) ) ,
590+ stepsWrapper = $ ( document . createElement ( options . stepsContainerTag ) )
591+ . addClass ( "steps" ) . append ( $ ( "<ul role=\"tablist\"></ul>" ) ) ,
591592 stepTitles = contentWrapper . children ( options . headerTag ) ,
592593 stepContents = contentWrapper . children ( options . bodyTag ) ;
593594
594595 // Transform the wizard wrapper and remove the inner HTML
595- wizard . attr ( "role" , "application" ) . addClass ( options . cssClass ) . empty ( ) . append ( contentWrapper ) ;
596+ wizard . attr ( "role" , "application" ) . addClass ( options . cssClass ) . empty ( )
597+ . append ( stepsWrapper ) . append ( contentWrapper ) ;
596598
597599 // Add WIA-ARIA support
598600 stepContents . each ( function ( index )
@@ -603,19 +605,9 @@ var privates = {
603605 // Make the start step visible
604606 stepContents . eq ( state . currentIndex ) . showAria ( ) ;
605607
606- var stepsWrapper = $ ( document . createElement ( options . stepsContainerTag ) )
607- . addClass ( "steps" ) . append ( $ ( "<ul role=\"tablist\"></ul>" ) ) ;
608- wizard . prepend ( stepsWrapper ) ;
609-
610608 stepTitles . each ( function ( index )
611609 {
612610 privates . renderTitle ( wizard , options , state , $ ( this ) , index ) ;
613-
614- // TODO: Try to move this code block to renderTitle
615- if ( index < state . currentIndex )
616- {
617- wizard . find ( ".steps li" ) . eq ( index ) . disableAria ( ) . addClass ( "done" ) ;
618- }
619611 } ) ;
620612
621613 privates . refreshStepNavigation ( wizard , options , state ) ;
@@ -737,6 +729,11 @@ var privates = {
737729 stepItem . disableAria ( ) ;
738730 }
739731
732+ if ( state . currentIndex > index )
733+ {
734+ stepItem . enableAria ( ) . addClass ( "done" ) ;
735+ }
736+
740737 header . setId ( uniqueHeaderId ) . attr ( "tabindex" , "-1" ) . addClass ( "title" ) ;
741738
742739 if ( index === 0 )
@@ -759,6 +756,9 @@ var privates = {
759756 {
760757 stepCollection . find ( "li" ) . removeClass ( "last" ) . eq ( index ) . addClass ( "last" ) ;
761758 }
759+
760+ // Register click event
761+ stepItem . children ( "a" ) . bind ( "click.steps" , privates . stepClickHandler ) ;
762762 } ,
763763
764764 /**
0 commit comments