Magento 2 Tabs – Change Programmatically

javascriptjquerymagento2tabs

I'm wondering how to exactly change tab (core mage/tabs widget) programmatically. Docs say that I can use both activate and enable functions for that: http://devdocs.magento.com/guides/v2.0/javascript-dev-guide/widgets/widget_tabs.html

Unfortunately, no one is recognized.

Tabs are initialized as follows:

var tabs = $('.tabs');
tabs.tabs({
    openedState: 'active-tab'
});

Initialization and other base things work fine. The issue occurs when I would like to change tab programmatically:

tabs.activate('3'); // Uncaught TypeError: tabs.activate is not a function

I'm not sure what I am doing wrong.

Best Answer

Inside vendor/magento/module-review/view/frontend/web/js/process-reviews.js:40 they are used like this:

$('.selector').tabs('activate', index);
Related Topic