Skip to content

Instantly share code, notes, and snippets.

@BenConstable
Last active December 16, 2015 09:18
Show Gist options
  • Save BenConstable/5411499 to your computer and use it in GitHub Desktop.
Save BenConstable/5411499 to your computer and use it in GitHub Desktop.
Allow jQuery UI Tabs that act as regular links.
<ul class="ui-tabs">
<li>
<a href="#tab-1">My Tab 1</a>
</li>
<li>
<a href="#tab-2">My Tab 2</a>
</li>
<li>
<a data-external="http://www.example.com">My External Tab</a>
</li>
</ul>
(function ($) {
$('.ui-tabs').tabs();
$('.ui-tabs a[data-external!=""]:[data-external]').on('click', function (e) {
e.preventDefault();
e.stopPropagation();
window.open($(this).data('external'), $(this).attr('target') || '_self');
});
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment