Determining tab index from ID

Determining tab index from ID


I have run into a snafu where it appears that I really need to be able
to determine the tab index from the tab id, or at least be able to
perform remove actions directly on an ID.
Background:
I have links that open new tabs. When these tabs are opened, I'd like
them to be closeable as well. The issue is that the links may be
clicked in any order, and the tabs may be closed in any order. This
means that the tab index is always unpredictable.
JS:
$("#newtab").click(function() {
if (!$(this).hasClass("shown")) {
$("#forums > ul").tabs("add", '#newtab-frag', 'New Frag <a
id=\"newtab-close\">close<\/a>');
$(this).toggleClass("shown");
}
$("#newtab-close").click(function() {
alert("close!");
});
});
HTML:
<a id="newtab">new tab</a>
Thoughts:
The above code works great. When the new tab is created you can click
the close link and the alert happens. The problem is I can't figure
out a way to determine the ID of the tab in order to use the
tabs("remove",...) because I don't know what the index is.
Can anyone offer any insight? Perhaps there is a way to set the index
as a class when the tab is created? Then I could at least more easily
look it up...