Change active tab on button click (Tabs_ClientSide)

Change active tab on button click (Tabs_ClientSide)

  
Hello,

I'm having a problem for a while now: how can I change a tab when the user click on a button? I'm talking about the Tabs_ClientSide widget.

I tried changing the InitialActiveTab property and then refreshing the page, but it does not work and, even if it worked, it's not the best way, because I don't want a page refresh (I have to keep some forms populated).

I thought that it will be simple but I cannot find another way of doing it... Maybe with some JavaScript?

Thank you,
Liviu
Hi Liviu,

I've achive this in the past by having keyboard shortcuts that simulated the clicks on the tabs. At the time a created a small script that simulated the click on at the maximum 9 tabs when you pressed ALT+F1 to first tab ALT+F2 to the second and so on.

It was something like this:

$(document).on('keyup', function (e) {

    try{

        //ALT+F1-ALT+F9

        if(e.altKey && e.keyCode >= 112 && e.keyCode <= 124){

            var currentTab = e.which-111;

           

            $('ul.Tabs_Header').find('li:nth-child(' + currentTab + ')').find('a').click();

        }

    }catch(e){}

});

This was done still on OutSystems platform 7 and I haven't used it before but you can try it and let us know if it helps.

Cheers,
Guilherme
Hi Guilherme,

Thanks for your reply.

I started looking into the DOM and using jQuery for changing active tabs, but I didn't have the time to finish something.

I thought to ask here, maybe there's an "out of the box" way of doing it.

Your code snippet is helpful, thanks a lot.

I'll come back with the code, maybe it helps somebody.