Support

Account

Home Forums Backend Issues (wp-admin) I have JS in ACF fields working but how about only when a tab is opened? Reply To: I have JS in ACF fields working but how about only when a tab is opened?

  • So I fixed this myself with two new conditions in a custom JS file that uses jquery within the WP admin.

    
    // run the code when the specific tab of the form group is clicked on
    jQuery(document).on('click','*[data-key="field_123456789"]', function(event){
        runCustomCodeFunction();
    });
    // also run my code if the page loads and this tab is visible (it isn't by default as it isn't the first tab)
    if ( jQuery(".acf-field-123456789:visible").length > 0 ) {
        runCustomCodeFunction();
    }