Bricksextras: Modify tab tab Pro so that the tab remains open when the browser is reloaded

Problem:

If you create different tabs in Tabreiter Pro and reload the page, only the 1st tab is opened. For an improved UX, it would be nice if the last tab opened remained open.

Solution:

  1. Switch on Hash URL in Pro Tabs (Open via URL parameter), GET parameter = tab
  2. Pro Tabs comes with its own JavaScript events. We need the "x_tabs:switch" event.
  3. The following code (initialisation in the footer and if possible only on pages in which the tabs also appear:
document.addEventListener("DOMContentLoaded", () => {
    const tabs = document.getElementById("myProTabsID");
    if (tabs) {
        tabs.addEventListener("x_tabs:switch", () => {
            const activeTabPanel = tabs.querySelector(".x-tabs_panel-current");
            if (activeTabPanel && activeTabPanel.id) {
                const activeTabId = activeTabPanel.id;
                const url = new URL(window.location); // Retrieve current URL
                url.searchParams.set('tab', activeTabId); // Set GET parameter 'tab'
                window.history.pushState({}, "", url); // Update URL without reloading
            }
        });
    }
});Code language: JavaScript (javascript)

Replace myProTabsID with the ID of the root element of "Pro Tabs"

See also

Shortcode E-Mail Obfuscator

The following shortcode snippet is useful for disguising emails to protect them from SPAM. Please note that this method only works if Javascript is activated. In addition, there is no 100%igen protection against bots,...

Elementor popup / flyout menu no longer closes for mobile view

Elementor: Version 3.72 Behaviour: An Elementor popup opens, but no longer closes (when clicking on icon or Esc or other triggers). If you look in the source code, you will find the Javascript error message: "Elementor t.entrance_animation_duration is undefined" Cause:...

PHPStorm: Local Changelist in Git Tool disappeared

Problem: Local Change List under PHPStorm is missing in the Git Tool Solution: From time to time I had the phenomenon that the Local Changelist (the files in my version control) were not visible as tabs in the Git tool....

Variable not available in blade component

Problem: The parameter transfer of a blade attribute does not work, the variable in the component is empty. There is no error message, but the variable does not appear to have been passed. Solution: The error may lie in the usage...

WP CLI Error: Error establishing a database connection.

Appearance: Submitting commands via WP CLI, but WordPress in the browser works. This error often occurs when the WP CL interpreter cannot correctly interpret the database connection in wp-config.php. Solution: In 99% of all cases the...

Convert Px to SEM / EM very quickly with Alfred

Auf dem Mac gibt es einen wunderbaren Alfred-Workflow, der Px in Rem umrechnet: Download Direktlink: https://raw.githubusercontent.com/vitorgalvao/requested-alfred-workflows/master/Workflows/Px%20Rem%20Em.alfredworkflow Einfach installieren, dann CMD-Space: Alfred Bar "pxrem" tippen und die Zahl in Pixel angeben. Die Umrechnung in REM wird…