UI Tabs - Automatically initialize inline links to activate tabs
Hi,
The following line, when added to the UI Tabs init() method, just
prior to the event handler binding, causes all links with href
attributes equivalent to those in tab nav to become tied to the tab
nav automatically.
this.$lis.each(function(){var tab=$('a[href]',this);$('a
[href='+tab.attr('href')+']').each(function(){if(this!=tab){$
(this).click(function(){tab.trigger(o.event+'.tabs');/*this should
probably scroll to the top of the appropriate tab nav*/window.scrollTo
(0,0);return false;});}});});
This thereby reduces the need for selecting tabs from text links via
the method described in the documentation:
http://docs.jquery.com/UI/Tabs#...select_a_tab_from_a_text_link_instead_of_clicking_a_tab_itself
A diff is below... Cheers!
--
Jake Kronika
==DIFF======================================================
$li.removeClass('ui-state-default').addClass(classes.join
(' '))
.siblings().removeClass(classes.join(' ')).addClass
('ui-state-default');
hideTab(clicked, $hide, $show);
}
+ this.$lis.each(function(){
+ var tab = $('a[href]',this);
+ $('a[href=' + tab.attr('href') + ']').each(function(){
+ if (this != tab) {
+ $(this).click(function(){
+ tab.trigger(o.event+'.tabs');
+ //this should probably scroll to the top of
the
+ //appropriate tab nav instead of the top of
the window
+ window.scrollTo(0,0);
+ //make sure that the default click event
isn't thrown
+ return false;
+ });
+ }
+ });
+ });
+
// attach tab event handler, unbind to avoid duplicates from
former tabifying...
this.$tabs.unbind('.tabs').bind(o.event + '.tabs', function()
{
//var trueClick = event.clientX; // add to history only if
true click occured, not a triggered click
==/DIFF======================================================