JQuery UI tabs: How do I navigate directly to a tab from another page?

Posted by Chris Simpson on Stack Overflow See other posts from Stack Overflow or by Chris Simpson
Published on 2010-03-31T17:06:26Z Indexed on 2010/03/31 17:13 UTC
Read the original article Hit count: 513

JQuery UI tabs are implemented by named anchors in an unordered list. When you hover over one of the tabs you can see this in the link shown at the foot of the browser:

http://mysite/product/3/#orders

Above would be the "orders" tab for example. JQuery obviously intercepts the click to this anchor and opens the tab instead.

However if I bookmark the link above or link to it from elsewhere in the site the page does not open on the specific tab.

In the tab initialisation block I was considering putting in some code that looks for a named anchor in the URL and, if it finds one, does an index lookup of the tabs and calls the select on it. This would mean it will still work with JS switched off.

But is there an easier/nicer/better way?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui