Robert O'Rourke wrote:

Hi everybody

I'm using Klaus' tabs plugin and was wondering how to return or pull out information like attribute values from the clicked tab.
   Is anything like this possible?

$("#mycontainer").tabs({ onClick: myFunction(args) });


Sorry if that's unclear. I can think of a slightly longer way to do things by finding the currently selected tab but was hoping there's a more elegant solution. Nice plugin by the way Klaus!

   Rob


Thank you Rob.

You're nearly there. Three arguments are passed to the onClick/onHide/onShow callbacks. The first one being the tab that was clicked (the anchor element), the second one the container that gets shown, and the third one the container that gets hidden:

$('#mycontainer').tabs({
    onClick: function(clicked, toShow, toHide) {
        alert(clicked.href);
        alert(toShow.id);
        alert(toHide.id);
    }
});

or by using args:

$('#mycontainer').tabs({
    onClick: function() {
        alert(args[0].href);
        alert(args[1].id);
        alert(args[2].id);
    }
});

To get the index of the currently selected tab you can always use the activeTab method:

$('#mycontainer').activeTab(); // => 2



--Klaus

Reply via email to