Support » Plugin: Tabs » Feature request: auto-click tab by bookmark

  • Let’s assume that we have a tab container on a page B which features 3 tabs:

    • tabs_desc_NNNN_1
    • tabs_desc_NNNN_2
    • tabs_desc_NNNN_3

    Let’s assume that the third tab element has an A anchor with aria-controls=”tabs_desc_NNNN_3″.

    By clicking the third tab item it becomes active, thus its associated tab content container is shown.

    Now, let’s imagine that I have a main page A where I have 3 links, each of them pointing to a given tab in page B. By pointing to a given tab “X” I mean /B#tabs_desc_NNNN_X.

    In the current version if I would open the /B#tabs_desc_NNNN_X page the first tab is shown by default, regardless of my tabs_desc_NNNN_X bookmark.

    It will be useful if the plugin would be smart enough to trigger the click event for the tab element given by the bookmark.

    I fixed this in one of our websites by enqueuing a custom JavaScript file for my theme, where the Javascript looks like this:

    jQuery( document ).ready(function() {
    	var p='.*\\/#(\\w+)$';
    	var r=RegExp(p);
    	if(r.test(document.location.href)){
    		var id=document.location.href.replace(r,'$1');
    		jQuery('li[role=presentation] a[role=tab][aria-controls='+id+']').trigger('click');
    	}
    });

    It will be nice if this fix could be added to the plugin code itself.

    • This topic was modified 11 months, 1 week ago by  Eugen Mihailescu. Reason: styling
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Feature request: auto-click tab by bookmark’ is closed to new replies.