Tabs can be loaded specifically when landing on a page, that’s part of the tabs functionality, but will not work with the “Set active tab” option enabled. In addition to that, selecting the active tab only works for the first time you land on the page and applicable anchor(it won’t switch tab using the anchors for any additional anchor references – that’s specific to the tabs script, not the plugin).
You could, as you’ve suggested, switch tabs using jQuery and calling the active tab setter.
jQuery(document).ready(function($){
$('#selector-for-your-button').click(function(){
$('#tabs-n').tabs( 'option', 'active', 0 ); // Selects the first tab
});
});
Where n in the tabs selector refers to the tabs instance, in your above example the n refers to 1.
The 0 in the tabs third argument refers to the key of the tab to select, the index starts at zero, first tab is 0, second is 1 and so on.
Hope that helps. 🙂
That helps a lot, thanks Mark!
Follow up question: When my custom link to a tab is clicked, the browser is scrolling to a position just below the anchor (in this case, the tab’s anchor tag). Seems like the expected behavior would be to scroll to the top of the anchor, so you can see the tabs. Any idea what’s going on, and how I might fix?
I’ve noticed the same behaviour, i’m not sure if that’s do with default anchor functionality, jquery ui/tabs or whether that’s related to my coding, but it’s one minor issue i’ve noticed in testing to.
I’ll let you know more if i manage to pin down the reasoning behind the weird anchor positioning.