Custom Fields
Re-Envisioned
Support Meta Box Tabs Custom button to switch tabs

This topic contains 1 reply, has 1 voice, and was last updated by  meta_gecko 1 year, 4 months ago.

  • Creator
    Topic
  • #10161
    Resolved
    meta_gecko
    Participant

    Hi,

    I’d like to add a button at the bottom of the page in the WP Admin beneath all the fields in a Tab to switch to the a different tab when clicked.

    I’ve been trying to add it using the html field, and basically just want to pass the click event from the button at the bottom to switch to the next tab (there are only two tabs).

    I can get it to switch, but because the event is set to prevent bubbling up, it does not remove the “rwmb-tab-active” class from the tab I’m switching away from.

    Also, if I go back to that tab, then my code has added the active panel class to the custom button.

    I can see why it isn’t working properly, but is anyone able to help me out with the correct callback?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #10165

    meta_gecko
    Participant

    My earlier reply has been put in quarantine because I tried to make it look a bit tidier..

    It said this below (please delete the duplicate):

    meh, close enough since this is a single implementation on a site, although I would still like to know how to write a variable function for this:

    jQuery( function( $ ) {
      $( '.wtv_switch' ).on( 'click', function(e) {
    
        if ($('.rwmb-tab-tax_filters').hasClass('rwmb-tab-active')) {
          $('.rwmb-tab-tax_filters').removeClass('rwmb-tab-active');
          $('.rwmb-tab-fact_compose').addClass('rwmb-tab-active');
        }
    
      $( '.rwmb-tab-active a' ).trigger( 'click' );
    
      });
    });
    
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.