Klaus Hartl schrieb:

Ariel Jakobovits schrieb:
I realize now that this was very specific to my project, and I got this to work.

Since i am loading all the elements of my page with AJAX, I had to wait for the tabs to be fully loaded, then simply add the content for each fragment.

It is a shame that there is no onClick or onShow fired for the first tab when the tabs() function is complete so that we could support lazy loading for the tab content, including the first tab.

That would be pretty easy to do, but it would also completely break existing pages.

The reason why there is no onclick fired for the first tab is that there is no click ;-)

That has also to do with support for back button...

Using the remote option though does result in lazy loading. So I still have the feeling that you're using the tabs in a way I didn't design them for. Or hacked something in that is supported elsehow (no offense here)...


BTW, I think it would be nice if there was a function defined $.fn.selectedTab(). I would try to write it myself, but I am still a little overwhelmed by the code.

Here we go:

jQuery.fn.selectedTab = function() {
    var selectedTabs = [];
    this.each(function() {
        var nav = jQuery('ul.tabs-nav' , this);
nav = nav.size() && nav || jQuery('>ul:eq(0)', this); // fallback to default structure
        var lis = jQuery('li', nav);
selectedTabs.push(lis.index( lis.filter('.tabs-selected')[0] ) + 1);
    });
    return selectedTabs.length > 1 ? selectedTabs : selectedTabs[0];
};

It returns a number if you check for one tab interface

$('#container').selectedTab(); // => 1

and an array if you check for multiple interfaces:

$('#container-1, #container-2').selectedTab(); // => [1, 1]

As usual for the plugin it is not a zero-based index. Thus you can do:

var tabs = $('#container-1');
tabs.disableTab(tabs.selectedTab());


And it re


Reply via email to