I am trying to find a way to change window.location.hash to the currently selected tab in the JQuery UI Tabs .
I tried:
$("#tabs > ul").tabs(); $("#tabs > ul").bind("tabsshow", function(event, ui) { window.location.hash = ui.tab; })
This causes the hash to change to # undefined when the tab changes.
I also tried:
$("#tabs > ul").tabs({ select: function(event, ui) { window.location.hash = ui.tab } });
But this does not seem to work at all.
Any help would be greatly appreciated. Thank.
Edit: it looks like part of my original problem had something to do with js somewhere else, interfering with this. Both the accepted answer and the other proposed answer are slightly modified, work. Thanks to everyone.
jquery jquery-ui fragment-identifier tabs
Rob Feb 20 '09 at 16:35 2009-02-20 16:35
source share