VinceG / twitter-bootstrap-wizard

This twitter bootstrap plugin builds a wizard out of a formatter tabbable structure. It allows to build a wizard functionality using buttons to go through the different wizard steps and using events allows to hook into each step individually.
MIT License
1.39k stars 676 forks source link

Useful Snippet: How to detect which tab (by name) you are on. #232

Open samjco opened 5 years ago

samjco commented 5 years ago
$('#rootwizard').bootstrapWizard({onTabShow: function(tab, navigation, index){

var currTabURL = tab.context.toString(),
      getFullUrl = window.location;

// current tab with url
console.log('current tab url= '+currTabURL);
// current full url
console.log('complete url= '+getFullUrl);
// just the current tab
var currTab = currTabURL.replace(getFullUrl, "");
console.log('just the tab= '+currTab);

// Then you can do something like:
 if (currTab == '#your-tab-name'){
  //do something
 }else(
  //do something
 }

}});