From ee34b1fcb8f0af90e1f640c4ce1add246ab49d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Balicki?= Date: Tue, 5 Jan 2021 10:42:48 +0100 Subject: [PATCH] Open specific tab from hyperlink --- src/js/tab.js | 10 ++++++++++ src/js/tabler.js | 1 + 2 files changed, 11 insertions(+) create mode 100644 src/js/tab.js diff --git a/src/js/tab.js b/src/js/tab.js new file mode 100644 index 000000000..fcc293ec5 --- /dev/null +++ b/src/js/tab.js @@ -0,0 +1,10 @@ +const locationHash = window.location.hash; + +if (locationHash) { + const tabsList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tab"]')); + const matchedTabs = tabsList.filter(tab => tab.hash === locationHash); + + matchedTabs.map(tab => { + new bootstrap.Tab(tab).show(); + }); +} diff --git a/src/js/tabler.js b/src/js/tabler.js index f221ae301..940c64715 100644 --- a/src/js/tabler.js +++ b/src/js/tabler.js @@ -3,6 +3,7 @@ import './autosize'; import './input-mask'; import './dropdown'; +import './tab'; (function() { /**