8.4.2: select ui tab programmatically

Permalink
I have tabs on a page with pagination:
echo $app->make('helper/concrete/ui')->tabs([
    ['tab1', t('Tab1'), true],
    ['tab2', t('Tab2')],
    ['tab3', t('Tab3')],
    ...
]);

Is there any way to select one of the tabs programmatically so that the page redirects directly to it after clicking the page link? Or it's not possible because the page reloads together with the script?

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
$(document).ready(function() {
    var url = window.location.pathname.toString();
    var tab = window.sessionStorage.getItem('tab');
    if (tab != '') {
        $('ul.nav-tabs li').removeClass('active');
        $('ul.nav-tabs li a[data-tab="' + tab + '"]').parent().addClass('active');
        $('ul.nav-tabs li a[data-tab="' + tab + '"]').trigger('click');
        var url_array = url.split('/');
        if (!url_array.includes('edit')) {
            window.sessionStorage.setItem('tab', '');
        }
    }
    $('ul.nav-tabs li a').on('click', function(e) {
        var t = $(this).attr('data-tab');
        window.sessionStorage.setItem('tab', t);