Skip to content

Instantly share code, notes, and snippets.

@jsheely
Created May 11, 2013 01:58
Show Gist options
  • Save jsheely/5558625 to your computer and use it in GitHub Desktop.
Save jsheely/5558625 to your computer and use it in GitHub Desktop.
Enable tabs that can be linked to directly by url ex. www.example.com/page.aspx#tab2
jQuery(document).ready(function(){
var tabCollection="#tab-instanceId";
var selectedTabHash = "#tab_" + window.location.hash.replace(/#/,"");
$(tabCollection).tabs()
.bind("tabsshow",function(event,ui){window.location.hash=ui.tab.hash.replace(/#/,"").replace(/tab_/,"");})
.tabs("select", selectedTabHash);
$(window).bind('hashchange', function() {
$(tabCollection).tabs( "select" , "#tab_" + window.location.hash.replace(/#/,""));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment