Skip to main content

Search and Top Navigation

#4133 closed bug (notabug)

Opened February 12, 2009 12:11PM UTC

Closed February 13, 2009 11:25PM UTC

Last modified May 09, 2010 06:15PM UTC

Creating a new tab causes url to change

Reported by: aleemb Owned by:
Priority: major Milestone: 1.7
Component: ui.tabs Version: 1.6rc6
Keywords: Cc:
Blocked by: Blocking:

This is causing all sort of issues on my end. The scenario is that I have a tab labelled "+" which if clicked adds a new tab:

$('#mytabs').tabs({ 'select' : this._tabClick });
_tabClick : function(event, ui) {
if ( == 'add') // user clicks "+" tab
	$('#mytabs').tabs('add', '#newtab', 'new tab', ui.index);

The last statement which adds the new tab is triggering the bug. The URL changes to where add is the href for the "+" tab. This doesn't happen in rc5 or rc6 but only in the code that's in the trunk.

To mitigate I have had to change the last line to:

setTimeout(function(){$('#mytabs').tabs('add', '#newtab', 'new tab', ui.index); }, 1);

Which doesn't cause the url to change.

There is another issue with the URL being changed. Since the browser already points to clicking the "+" tab doesn't work (doesn't trigger the select handler _tabClick).

There is yet another issue here in that in the _tabClick handler function I immediately wanted to select the just added tab for which I was using:


that didn't work (in rc5, rc6 or trunk) but I suspected a race condition so tried the following which worked:

setTimeout(function(){$('#mytabs').find('a[href=#newtab]').click();}, 1);
Attachments (0)
Change History (5)

Changed February 12, 2009 06:00PM UTC by klaus.hartl comment:1

IE only?

Changed February 12, 2009 08:38PM UTC by aleemb comment:2

Both IE7 and FF3 have the issue.

Changed February 12, 2009 11:37PM UTC by jzaefferer comment:3

milestone: TBD1.6
priority: criticalmajor

Have you tried adding "return false" in the select-handler?

Changed February 13, 2009 04:12AM UTC by aleemb comment:4

Missed that one... it's a better work around. Using that instead now instead of setTimeout. (had earlier tried stopPropagation and stopImmediatePropagation both of which didn't work).

Changed February 13, 2009 11:25PM UTC by klaus.hartl comment:5

resolution: → invalid
status: newclosed

I couldn't duplicate the first error. Regarding selecting a just added tab, see also

The url changing is duplicate: #4134