@@ -379,6 +379,10 @@ $.fn.tab = function(parameters) {
379
379
module . verbose ( 'Tab parameters found' , nextPathArray ) ;
380
380
}
381
381
}
382
+ if ( settings . onBeforeChange . call ( element , currentPath ) === false ) {
383
+ module . debug ( 'onBeforeChange returned false, cancelling tab change' , $tab ) ;
384
+ return false ;
385
+ }
382
386
if ( isLastTab && remoteContent ) {
383
387
if ( ! shouldIgnoreLoad ) {
384
388
module . activate . navigation ( currentPath ) ;
@@ -415,6 +419,10 @@ $.fn.tab = function(parameters) {
415
419
// if anchor exists use parent tab
416
420
if ( $anchor && $anchor . length > 0 && currentPath ) {
417
421
module . debug ( 'Anchor link used, opening parent tab' , $tab , $anchor ) ;
422
+ if ( settings . onBeforeChange . call ( element , currentPath ) === false ) {
423
+ module . debug ( 'onBeforeChange returned false, cancelling tab change' , $tab ) ;
424
+ return false ;
425
+ }
418
426
if ( ! $tab . hasClass ( className . active ) ) {
419
427
setTimeout ( function ( ) {
420
428
module . scrollTo ( $anchor ) ;
@@ -968,6 +976,7 @@ $.fn.tab.settings = {
968
976
onLoad : function ( tabPath , parameterArray , historyEvent ) { } , // called on every load
969
977
onVisible : function ( tabPath , parameterArray , historyEvent ) { } , // called every time tab visible
970
978
onRequest : function ( tabPath , parameterArray , historyEvent ) { } , // called ever time a tab beings loading remote content
979
+ onBeforeChange : function ( tabPath ) { } , // called before a tab is about to be changed. Returning false will cancel the tab change
971
980
972
981
templates : {
973
982
determineTitle : function ( tabArray ) { } // returns page title for path
0 commit comments