@@ -93,7 +93,7 @@ $.widget( "ui.tabs", {
93
93
// check for length avoids error when initializing empty list
94
94
if ( o . active >= 0 && this . anchors . length ) {
95
95
this . active = this . _findActive ( o . active ) ;
96
- var panel = self . element . find ( self . _sanitizeSelector ( this . active . attr ( "aria-controls" ) ) ) ;
96
+ var panel = self . _getPanelForTab ( this . active ) ;
97
97
98
98
panel . show ( ) ;
99
99
@@ -129,7 +129,7 @@ $.widget( "ui.tabs", {
129
129
} ,
130
130
131
131
_tabId : function ( a ) {
132
- return ( $ ( a ) . attr ( "aria-controls" ) || "" ) . replace ( / ^ # / , "" ) ||
132
+ return ( $ ( a ) . attr ( "aria-controls" ) || "" ) ||
133
133
"ui-tabs-" + getNextTabId ( ) ;
134
134
} ,
135
135
@@ -155,7 +155,7 @@ $.widget( "ui.tabs", {
155
155
156
156
// Remove panels that we created that are missing their tab
157
157
this . element . find ( ".ui-tabs-panel:data(destroy.tabs)" ) . each ( function ( index , panel ) {
158
- var anchor = self . anchors . filter ( "[aria-controls='# " + panel . id + "']" ) ;
158
+ var anchor = self . anchors . filter ( "[aria-controls='" + panel . id + "']" ) ;
159
159
if ( ! anchor . length ) {
160
160
$ ( panel ) . remove ( ) ;
161
161
}
@@ -248,7 +248,7 @@ $.widget( "ui.tabs", {
248
248
if ( panel . length ) {
249
249
self . panels = self . panels . add ( panel ) ;
250
250
}
251
- $ ( a ) . attr ( "aria-controls" , selector ) ;
251
+ $ ( a ) . attr ( "aria-controls" , selector . substring ( 1 ) ) ;
252
252
} ) ;
253
253
} ,
254
254
@@ -348,8 +348,8 @@ $.widget( "ui.tabs", {
348
348
clicked = $ ( event . currentTarget ) ,
349
349
clickedIsActive = clicked [ 0 ] === active [ 0 ] ,
350
350
collapsing = clickedIsActive && options . collapsible ,
351
- toShow = collapsing ? $ ( ) : that . element . find ( that . _sanitizeSelector ( clicked . attr ( "aria-controls" ) ) ) ,
352
- toHide = ! active . length ? $ ( ) : that . element . find ( that . _sanitizeSelector ( active . attr ( "aria-controls" ) ) ) ,
351
+ toShow = collapsing ? $ ( ) : that . _getPanelForTab ( clicked ) ,
352
+ toHide = ! active . length ? $ ( ) : that . _getPanelForTab ( active ) ,
353
353
tab = clicked . closest ( "li" ) ,
354
354
eventData = {
355
355
oldTab : active ,
@@ -397,7 +397,7 @@ $.widget( "ui.tabs", {
397
397
} ) ;
398
398
399
399
// TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
400
- that . load ( that . anchors . index ( clicked ) ) ;
400
+ that . load ( that . anchors . index ( clicked ) , event ) ;
401
401
402
402
clicked [ 0 ] . blur ( ) ;
403
403
return ;
@@ -415,7 +415,7 @@ $.widget( "ui.tabs", {
415
415
that . _showTab ( event , eventData ) ;
416
416
} ) ;
417
417
418
- that . load ( that . anchors . index ( clicked ) ) ;
418
+ that . load ( that . anchors . index ( clicked ) , event ) ;
419
419
} else {
420
420
throw "jQuery UI Tabs: Mismatching fragment identifier." ;
421
421
}
@@ -550,16 +550,19 @@ $.widget( "ui.tabs", {
550
550
return this ;
551
551
} ,
552
552
553
- load : function ( index ) {
553
+ load : function ( index , event ) {
554
554
index = this . _getIndex ( index ) ;
555
555
var self = this ,
556
556
o = this . options ,
557
557
a = this . anchors . eq ( index ) [ 0 ] ,
558
- panel = self . element . find ( self . _sanitizeSelector ( $ ( a ) . attr ( "aria-controls" ) ) ) ,
558
+ panel = self . _getPanelForTab ( a ) ,
559
559
// TODO until #3808 is fixed strip fragment identifier from url
560
560
// (IE fails to load from such url)
561
561
url = $ ( a ) . attr ( "href" ) . replace ( / # .* $ / , "" ) ,
562
- eventData = self . _ui ( a , panel [ 0 ] ) ;
562
+ eventData = {
563
+ tab : $ ( a ) ,
564
+ panel : panel
565
+ } ;
563
566
564
567
if ( this . xhr ) {
565
568
this . xhr . abort ( ) ;
@@ -574,9 +577,8 @@ $.widget( "ui.tabs", {
574
577
this . xhr = $ . ajax ( {
575
578
url : url ,
576
579
beforeSend : function ( jqXHR , settings ) {
577
- // TODO: pass relevant event
578
- return self . _trigger ( "beforeLoad" , null ,
579
- $ . extend ( { jqXHR : jqXHR , settings : settings } , eventData ) ) ;
580
+ return self . _trigger ( "beforeLoad" , event ,
581
+ $ . extend ( { jqXHR : jqXHR , ajaxSettings : settings } , eventData ) ) ;
580
582
}
581
583
} ) ;
582
584
@@ -585,10 +587,10 @@ $.widget( "ui.tabs", {
585
587
this . lis . eq ( index ) . addClass ( "ui-tabs-loading" ) ;
586
588
587
589
this . xhr
588
- . success ( function ( response ) {
590
+ . success ( function ( response ) {
589
591
panel . html ( response ) ;
590
592
} )
591
- . complete ( function ( jqXHR , status ) {
593
+ . complete ( function ( jqXHR , status ) {
592
594
if ( status === "abort" ) {
593
595
// stop possibly running animations
594
596
self . element . queue ( [ ] ) ;
@@ -603,7 +605,7 @@ $.widget( "ui.tabs", {
603
605
604
606
self . lis . eq ( index ) . removeClass ( "ui-tabs-loading" ) ;
605
607
606
- self . _trigger ( "load" , null , eventData ) ;
608
+ self . _trigger ( "load" , event , eventData ) ;
607
609
} ) ;
608
610
}
609
611
@@ -645,27 +647,27 @@ if ( $.uiBackCompat !== false ) {
645
647
646
648
this . element . bind ( "tabsbeforeload" , function ( event , ui ) {
647
649
// tab is already cached
648
- if ( $ . data ( ui . tab , "cache.tabs" ) ) {
650
+ if ( $ . data ( ui . tab [ 0 ] , "cache.tabs" ) ) {
649
651
event . preventDefault ( ) ;
650
652
return ;
651
653
}
652
654
653
- $ . extend ( ui . settings , self . options . ajaxOptions , {
655
+ $ . extend ( ui . ajaxSettings , self . options . ajaxOptions , {
654
656
error : function ( xhr , s , e ) {
655
657
try {
656
658
// Passing index avoid a race condition when this method is
657
659
// called after the user has selected another tab.
658
660
// Pass the anchor that initiated this request allows
659
661
// loadError to manipulate the tab content panel via $(a.hash)
660
- self . options . ajaxOptions . error ( xhr , s , ui . index , ui . tab ) ;
662
+ self . options . ajaxOptions . error ( xhr , s , ui . tab . closest ( "li" ) . index ( ) , ui . tab [ 0 ] ) ;
661
663
}
662
664
catch ( e ) { }
663
665
}
664
666
} ) ;
665
667
666
668
ui . jqXHR . success ( function ( ) {
667
669
if ( self . options . cache ) {
668
- $ . data ( ui . tab , "cache.tabs" , true ) ;
670
+ $ . data ( ui . tab [ 0 ] , "cache.tabs" , true ) ;
669
671
}
670
672
} ) ;
671
673
} ) ;
@@ -876,7 +878,7 @@ if ( $.uiBackCompat !== false ) {
876
878
877
879
var _tabId = prototype . _tabId ;
878
880
prototype . _tabId = function ( a ) {
879
- return ( $ ( a ) . attr ( "aria-controls" ) || "" ) . replace ( / ^ # / , "" ) ||
881
+ return ( $ ( a ) . attr ( "aria-controls" ) || "" ) ||
880
882
a . title && a . title . replace ( / \s / g, "_" ) . replace ( / [ ^ \w \u00c0 - \uFFFF - ] / g, "" ) ||
881
883
this . options . idPrefix + getNextTabId ( ) ;
882
884
} ;
0 commit comments