admin管理员组

文章数量:1122846

Im wanting to force a page to load and have a particular dynamic tab as active.

Here’s the context: As seen the “Artworks” screen dumps below when a course is selected screen 1 displays with the focus on the dynamic tab “Overview” which is good at this point. The user then clicks the “Curriculum” tab and the content for this tab is then displayed on the same page as the “Overview”, screen2. The user then selects the appropriate lesson, and a new page is displayed, screen 3. The lesson page has a button that when pressed takes the user back to the Course Summary screen 1. However, this time I want the the “Curriculum” tab and content to be active.

I have a filter in a functions php file that currently triggers after (can be before if needed) the summary page is loaded and its in there I thought I’d put the solution script.

function psb_main_content_func( ){
        echo ('hello from the main content hook!');
        echo    "
            <script> 
                             .... something goes in here ...
            </script> ";
    } 
add_filter( 'learn-press/after-main-content', 'psb_main_content_func' );

That’s not the problem though. The problem is that I don’t know how to force screen 1 to load with “Curriculum” tab and content as active. Even using the browser inspect console I cant get it to go correctly. I’ve tried various combinations of getElement…. tried removing and adding the .active class.

Here are the relevant elements

Can someone can point me in right direction please. Thanks Paul

Im wanting to force a page to load and have a particular dynamic tab as active.

Here’s the context: As seen the “Artworks” screen dumps below when a course is selected screen 1 displays with the focus on the dynamic tab “Overview” which is good at this point. The user then clicks the “Curriculum” tab and the content for this tab is then displayed on the same page as the “Overview”, screen2. The user then selects the appropriate lesson, and a new page is displayed, screen 3. The lesson page has a button that when pressed takes the user back to the Course Summary screen 1. However, this time I want the the “Curriculum” tab and content to be active.

I have a filter in a functions php file that currently triggers after (can be before if needed) the summary page is loaded and its in there I thought I’d put the solution script.

function psb_main_content_func( ){
        echo ('hello from the main content hook!');
        echo    "
            <script> 
                             .... something goes in here ...
            </script> ";
    } 
add_filter( 'learn-press/after-main-content', 'psb_main_content_func' );

That’s not the problem though. The problem is that I don’t know how to force screen 1 to load with “Curriculum” tab and content as active. Even using the browser inspect console I cant get it to go correctly. I’ve tried various combinations of getElement…. tried removing and adding the .active class.

Here are the relevant elements

Can someone can point me in right direction please. Thanks Paul

Share Improve this question asked May 9, 2024 at 6:04 pbeepbee 52 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It seems like a tab is made active by the associative radio input element being checked. Thus, you'd want to select the tab-curriculum-input input element and set it to checked:

document.getElementById('tab-curriculum-input').checked = true

本文标签: How to force a page to load and have a particular dynamic tab as active