Custom button to switch tabs

Support MB Tabs Custom button to switch tabsResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10161
    meta_geckometa_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?

    #10165
    meta_geckometa_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 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.