Skip to main content

Search and Top Navigation

#3171 closed enhancement (fixed)

Opened August 09, 2008 04:45AM UTC

Closed July 16, 2010 05:10PM UTC

Last modified November 19, 2010 06:26PM UTC

have option to remove tab by href content, not just by index

Reported by: Owned by: klaus.hartl
Priority: minor Milestone: 1.8.3
Component: ui.tabs Version: 1.6rc6
Keywords: Cc:
Blocked by: Blocking:

My system generates tabs on runtime, with UUIDs as the ID attribute to ensure uniqueness. This way the menu has an href=#<uuid>, and the div has id=#<uuid>. Tracking the index of each content is tiresome, and deletion requires re-scanning the menu and updating the indexes so that I can delete the content correctly. It would be better (for me at least) if I also could use the code:


and not care about the indexes (which are useful in other circumstances).

Attachments (1)
  • patch_3171.patch (2.8 KB) - added by francois April 30, 2009 12:34PM UTC.

    remove, enable and disable tab by href

Change History (15)

Changed August 09, 2008 05:33AM UTC by brazilianjoe comment:1

I noticed that I can use the select function to select a tab by the href. I digged the tabs code and copied 2 lines of the tabs select function to the remove function, and the enhancement request I made came true.

I just copied those 2 lines from the tabs(select) action to tabs(remove), this way I can delete by the href as wel as the index. Should be trivial to add those 2 lines to the next release.

if (typeof index == 'string')

index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );

Changed August 17, 2008 10:17AM UTC by Cloudream comment:2

component: ui.coreui.tabs
milestone: → TDB
owner: paulklaus.hartl
priority: majorminor

Changed February 20, 2009 05:41PM UTC by brazilianjoe comment:3

Hi, klaus.hartl!

I want to give you heads-up on this bug. It's a no-brainer, and will add a good functionality to jQuery tabs.

as of jQuery 1.6rc6, function remove begins like this:

/ when generated by themeroller, the remove() function is in line 5681


remove: function(index) {

var o = this.options, $li = this.$lis.eq(index).remove(),

$panel = this.$panels.eq(index).remove();


you just have to change it to:


remove: function(index) {

if (typeof index == 'string')

index = this.$tabs.index( this.$tabs.filter('[href$=' + index + ']')[0] );

var o = this.options, $li = this.$lis.eq(index).remove(),

$panel = this.$panels.eq(index).remove();


And fix with this bug/enhancement.

This enables the possibility of removing a tab using the tab's href property without losing the ability to remove according to the tab index.

Please add this feature! I need this and can patch jQuery tabs every new version, but I bet it will be a nice feature for others too.

best regards

Changed February 20, 2009 08:47PM UTC by klaus.hartl comment:4

I'm considering to add that functionality, but: if so, I'd like to add that consistently to all methods where it applies.

Changed February 22, 2009 12:03PM UTC by klaus.hartl comment:5

milestone: TBD1.7

Changed March 08, 2009 02:29PM UTC by rdworth comment:6

milestone: 1.71.8

Changed April 30, 2009 12:36PM UTC by francois comment:7

With this patch I think tabs is more coherent.

Changed February 05, 2010 01:14PM UTC by brazilianjoe comment:8

Just to give the heads up, since the last post is 9 months old. Will this be implemented in 1.8? Pretty please? I haven't found any mention of it being implemented on the changelogs up to 1.8rc1.

Changed June 18, 2010 12:12AM UTC by francois comment:9

patch updated with latest version of jquery-ui. Available here

Changed July 01, 2010 02:30PM UTC by remoteportal comment:10

Respectfully, this seems like a "no brainer" feature enhancement... and it's so trivial to add, how come it's taking so long to get this the code base? The tab component will be MUCH easier to use if this fix is in place for all applicable verbs.

Changed July 12, 2010 09:42PM UTC by brazilianjoe comment:11

placed my version of a patch on github. I tried to make it as small as possible, without sacrificing readability and maintainability, and change as little as possible. Hope you find this code acceptable:

Changed July 13, 2010 12:01PM UTC by brazilianjoe comment:12

Further comments on my proposed changes to jquery.ui.tabs.js:

I have created a small helper function for internal use only. It is called _getIndex(). It receives the index variable, and parses it. if it is a string, it assumes it contains a href and looks for a tab with this href in the <a> link at the tab top. If it finds no tab, it returns NaN.

Next, it checks if it is a number, and similarly sanitizes it to a valid number.

It always returns a typeof number , thus required very little change on the other functions which can benefit from this behaviour.

I have used _getIndex to implement href functionality to the methods enable, disable, select, remove and load.

Changed July 16, 2010 05:10PM UTC by scottgonzalez comment:13

resolution: → fixed
status: newclosed

Fixed in fde8c64.

Changed August 04, 2010 01:25AM UTC by scottgonzalez comment:14


Changed November 19, 2010 06:26PM UTC by Tiago Freire comment:15

Tabs: Added ability to reference tabs by href. Fixes #3171 - have option to remove tab by href content, not just by index.

Changeset: fde8c64fd37d6700e174ccf5ea1574e418db2c1e