Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#4133 closed bug (notabug)

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);

Change History (5)

comment:1 Changed 14 years ago by klaus.hartl

IE only?

comment:2 Changed 14 years ago by aleemb

Both IE7 and FF3 have the issue.

comment:3 Changed 14 years ago by Jörn Zaefferer

Milestone: TBD1.6
Priority: criticalmajor

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

comment:4 Changed 14 years ago by aleemb

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).

comment:5 Changed 14 years ago by klaus.hartl

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

Note: See TracTickets for help on using tickets.