Skip to content

Instantly share code, notes, and snippets.

@mraichelson
Created February 20, 2010 03:27
Show Gist options
  • Save mraichelson/309477 to your computer and use it in GitHub Desktop.
Save mraichelson/309477 to your computer and use it in GitHub Desktop.
// find embedded links to other tabs and trigger tab behavior when they are clicked.
$j('div.tabContent a').each(function(i){
var theLinkUrl = $j(this).attr('href');
// if the link contains an #
if(theLinkUrl.indexOf('#') != -1){
// check if the # is on the same page (blank in !IE, doc.location in IE)
if( theLinkUrl.split('#')[0] == '' || theLinkUrl.split('#')[0] == document.location ){
// when clicking the link, trigger the link in ul.tabs that links to the same ID
$j(this).bind(
'click',
function(){
$j('ul.tabs>li a[href="#'+theLinkUrl.split('#')[1]+'"]').trigger('click');
// kill focus on the link and cancel the attempted clickthrough
this.blur();
return false;
}
);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment