Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've added a help section using the add_help_tab() function. I'd like to be able to click a link somewhere on the theme/plugin page and have the help panel open at whichever tab I need. Can someone help me out with the required JS for this?

Each tab panel has a unique hash link associated with it so I'd need to use this somehow I'm guessing

/themes.php?page=theme_options#tab-panel-general 
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Maybe the Q is bordering the off-topic, but IMO interesting in WordPress context.

I've tested this directly in FireBug, in the Dashboard page (wp-admin/index.php).

var $ =jQuery.noConflict();

// Remove 'active' class from all link tabs
$('li[id^="tab-link-"]').each(function(){
    $(this).removeClass('active');
});

// Hide all panels
$('div[id^="tab-panel-"]').each(function(){
    $(this).css('display','none');
});

// Set our desired link/panel
$('#tab-link-help-content').addClass('active');
$('#tab-panel-help-content').css('display','block');

// Force click on the Help tab
$('#contextual-help-link').click();
share|improve this answer
    
Thanks. The animation becomes a bit jerky when I try and use it within a click function for my links, however it works and will do for now :) –  Andrew Dec 13 '12 at 22:29
    
@Andrew, maybe you can take it to StackOverflow to see if improvements are possible. Glad it helped, g'luck :) –  brasofilo Dec 13 '12 at 23:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.