#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: |
Description
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 (ui.tab.id == '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 http://myurl.com/#add 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 http://myurl.com/#add 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:
$('#mytabs').find('a[href=#newtab]').click();
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
comment:3 Changed 14 years ago by
Milestone: | TBD → 1.6 |
---|---|
Priority: | critical → major |
Have you tried adding "return false" in the select-handler?
comment:4 Changed 14 years ago by
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
Resolution: | → invalid |
---|---|
Status: | new → closed |
I couldn't duplicate the first error. Regarding selecting a just added tab, see also http://docs.jquery.com/UI/Tabs#...immediately_select_a_just_added_tab
The url changing is duplicate: #4134
IE only?