Support » Plugin: Post UI Tabs » External link to tab?

  • Resolved protohominid

    (@protohominid)


    I’d like to create a custom button on the page that links to a particular tab. I tried linking to the corresponding tab’s anchor (e.g. “#tabs-1-2”) but that didn’t work. Do I need some custom jQuery to do it, and if so, what would be the best way?

    Thanks!

    http://wordpress.org/extend/plugins/put/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mark / t31os

    (@t31os_)

    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!

    Plugin Author Mark / t31os

    (@t31os_)

    Happy to help.. 🙂

    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?

    Plugin Author Mark / t31os

    (@t31os_)

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘External link to tab?’ is closed to new replies.