Sergey
Sergey

Reputation: 8091

Is it possible to fire event on jquery tabs plugin when we switch tabs

I use jquery tabs plugin, but can't figure out how to set the event when user switches between tabs.

Please help.

Upvotes: 0

Views: 980

Answers (2)

KingKongFrog
KingKongFrog

Reputation: 14429

activate( event, ui )

Triggered after a tab has been activated (after animation completes). If the tabs were previously collapsed, ui.oldTab and ui.oldPanel will be empty jQuery objects. If the tabs are collapsing, ui.newTab and ui.newPanel will be empty jQuery objects.

$( ".selector" ).tabs({
    activate: function( event, ui ) {}
});

Bind an event listener to the tabsactivate event:

$( ".selector" ).on( "tabsactivate", function( event, ui ) {} );

Upvotes: 1

Rory McCrossan
Rory McCrossan

Reputation: 337626

You're looking for the activate() event.

$(".selector").tabs({
    activate: function(event, ui) {
        alert("You changed tabs");
        // Or do something more constructive...
    }
});

Upvotes: 5

Related Questions