How to keep current tab active after page refresh using jquery? - html

Hi I am tying to keep current tab active after page reload refresh but unfortunatly it's not working what's my mistake Does anyone know please help me thanks.
HTML View
<!-- Tabs navs -->
<ul class="nav nav-tabs mb-5" id="ex1" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="ex1-tab-1" data-mdb-toggle="tab" href="#ex1-tabs-1" role="tab"
aria-controls="ex1-tabs-1" aria-selected="true">Slots</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link " id="ex1-tab-2" data-mdb-toggle="tab" href="#ex1-tabs-2" role="tab"
aria-controls="ex1-tabs-2" aria-selected="false">Booking List</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="ex1-tab-3" data-mdb-toggle="tab" href="#ex1-tabs-3" role="tab"
aria-controls="ex1-tabs-3" aria-selected="false">Rooms</a>
</li>
</ul>
<!-- Tabs navs -->
<div class="tab-pane fade" id="ex1-tabs-1" role="tabpanel" aria-labelledby="ex1-tab-1">
Tab one
</div>
<div class="tab-pane fade" id="ex1-tabs-2" role="tabpanel" aria-labelledby="ex1-tab-2">
Tab Two
</div>
<div class="tab-pane fade" id="ex1-tabs-3" role="tabpanel" aria-labelledby="ex1-tab-3">
Tab Three
</div>
Script
$(document).ready(function(){
$('a[data-mdb-toggle="tab"]').on('show.bs.tab', function(e) {
localStorage.setItem('activeTab', $(e.target).attr('href'));
});
var activeTab = localStorage.getItem('activeTab');
if(activeTab){
$('#ex1 a[href="' + activeTab + '"]').tab('show');
}
});

Here is the working code snippet:
$(document).ready(function () {
$('.tab-link').on('click', function (e) {
localStorage.setItem('activeTab', $(this).attr('href'));
$(this).tab('show');
});
var activeTab = localStorage.getItem('activeTab');
if (activeTab) {
$('#ex1 a[href="' + activeTab + '"]').tab('show');
}
});
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.bundle.min.js"
integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa"
crossorigin="anonymous"></script>
<!-- Tabs navs -->
<ul class="nav nav-tabs mb-5" id="ex1" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link tab-link active" id="ex1-tab-1" data-mdb-toggle="tab" href="#ex1-tabs-1" role="tab" aria-controls="ex1-tabs-1" aria-selected="true">Slots</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link tab-link" id="ex1-tab-2" data-mdb-toggle="tab" href="#ex1-tabs-2" role="tab" aria-controls="ex1-tabs-2" aria-selected="false">Booking List</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link tab-link" id="ex1-tab-3" data-mdb-toggle="tab" href="#ex1-tabs-3" role="tab" aria-controls="ex1-tabs-3" aria-selected="false">Rooms</a>
</li>
</ul>
<!-- Tabs navs -->
<div class="tab-pane fade" id="ex1-tabs-1" role="tabpanel" aria-labelledby="ex1-tab-1">
Tab one
</div>
<div class="tab-pane fade" id="ex1-tabs-2" role="tabpanel" aria-labelledby="ex1-tab-2">
Tab Two
</div>
<div class="tab-pane fade" id="ex1-tabs-3" role="tabpanel" aria-labelledby="ex1-tab-3">
Tab Three
</div>
Note: localStorage is disabled on Stackoverflow, so please execute this snippet on your local environment.

Related

Single tab multiple content bootstrap 5

I am working on bootstrap tabs, I am trying for the single tab with multiple content div's. I have tried by using two data-target values like data-target=".etab-p1, .etabi-img1".but it only works on bootstrap 4,Its not work on bootstrap 5,how is it work on bootstrap 5?
<body>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<ul id="myTab" class="nav nav-tabs" role="tablist">
<li class="nav-item"><a class="nav-link active show" href="#tab-1" data-bs-target=".etab-p1, .etabi-img1" data-toggle="tab">C1</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-2" data-bs-target=".etab-p2, .etabi-img2" data-toggle="tab">C2</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-3" data-bs-target=".etab-p3, .etabi-img3" data-toggle="tab">C3</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-4" data-bs-target=".etab-p4, .etabi-img4" data-toggle="tab">C4</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-5" data-bs-target=".etab-p5, .etabi-img5" data-toggle="tab">C5</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-6" data-bs-target=".etab-p6, .etabi-img6" data-toggle="tab">C6</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade show active etab-p1">
<p>Content 1.</p>
</div>
<div class="tab-pane fade etab-p2">
<p>Content 2.</p>
</div>
<div class="tab-pane fade etab-p3">
<p>Content 3.</p>
</div>
<div class="tab-pane fade etab-p4">
<p>Content 4.</p>
</div>
<div class="tab-pane fade etab-p5">
<p>Content 5.</p>
</div>
<div class="tab-pane fade etab-p6">
<p>Content 6.</p>
</div>
</div>
<div class="tab-content">
<div class="tab-pane fade show active etabi-img1">
<p>Content 111.</p>
</div>
<div class="tab-pane fade etabi-img2">
<p>Content 2222.</p>
</div>
<div class="tab-pane fade etabi-img3">
<p>Content 3333.</p>
</div>
<div class="tab-pane fade etabi-img4">
<p>Content 4444.</p>
</div>
<div class="tab-pane fade etabi-img5">
<p>Content 5555.</p>
</div>
<div class="tab-pane fade etabi-img6">
<p>Content 6666.</p>
</div>
</div>
<sctipt>
$('#myTab a[data-bs-toggle="tab"]').on('show.bs.tab', function(e) {
let target = $(e.target).data('bs-target');
$(target)
.addClass('active show')
.siblings('.tab-pane.active')
.removeClass('active show')
});
</script>
</body>
Did you read the part of the Bootstrap 5 docs that says "Dropped jQuery dependency and rewrote plugins to be in regular JavaScript"?
Therefore you need to include jQuery, and fix the markup to use data-bs-toggle.
<ul id="myTab" class="nav nav-tabs" role="tablist">
<li class="nav-item"><a class="nav-link active show" href="#tab-1" data-bs-target=".etab-p1, .etabi-img1" data-bs-toggle="tab">C1</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-2" data-bs-target=".etab-p2, .etabi-img2" data-bs-toggle="tab">C2</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-3" data-bs-target=".etab-p3, .etabi-img3" data-bs-toggle="tab">C3</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-4" data-bs-target=".etab-p4, .etabi-img4" data-bs-toggle="tab">C4</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-5" data-bs-target=".etab-p5, .etabi-img5" data-bs-toggle="tab">C5</a></li>
<li class="nav-item"><a class="nav-link" href="#tab-6" data-bs-target=".etab-p6, .etabi-img6" data-bs-toggle="tab">C6</a></li>
</ul>
https://codeply.com/p/E0uoClzJZo

How to stretch bootstrap5 text area in tabs

I would like to place a text area within the tab and stretch it horizontally and vertically within the card body.
However, using d-flex and align-self-stretch does not seem to work on the tab content div.
Here is what I have tried. I used bootstrap5 to place tabs with text areas inside cards.
I added a d-flex flex-column class to the card-body.
I added d-flex align-self-stretch to the tab content <div class="tab-content">
I have set display: flex from css, since there seems to be no flex in the div attribute.
However, the tab content does not fill the extra space in the card.
Is there any solution to this problem?
Thank you.
Here is a simple code that reproduces the problem.
https://codepen.io/sankai0044/pen/abEXaoJ
Here is the code.
.card{
width: 400px;
height: 300px;
}
.tab-content{
display: flex;
}
.tab-pane{
width: 100%;
height: 100%;
}
.form-group{
width: 100%;
height: 100%;
}
#MyTextarea{
resize: none;
}
<head>
<script src="https://code.jquery.com/jquery-3.6.0.slim.js" integrity="sha256-HwWONEZrpuoh951cQD1ov2HUK5zA5DwJ1DNUXaM6FsY=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<div class="card">
<div class="card-header">
Header
</div>
<div class="card-body d-flex flex-column">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="home-tab"
data-bs-toggle="tab"
data-bs-target="#home"
type="button"
role="tab"
aria-controls="home"
aria-selected="true"
>
Home
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="profile-tab"
data-bs-toggle="tab"
data-bs-target="#profile"
type="button"
role="tab"
aria-controls="profile"
aria-selected="false"
>
Profile
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="contact-tab"
data-bs-toggle="tab"
data-bs-target="#contact"
type="button"
role="tab"
aria-controls="contact"
aria-selected="false"
>
Contact
</button>
</li>
</ul>
<div class="tab-content d-flex align-self-stretch" id="myTabContent">
<div
class="tab-pane fade show active"
id="home"
role="tabpanel"
aria-labelledby="home-tab"
>
<div class="form-group">
<textarea class="form-control" id="MyTextarea" disabled>This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.</textarea>
</div>
</div>
<div
class="tab-pane fade"
id="profile"
role="tabpanel"
aria-labelledby="profile-tab"
>
Profile Content
</div>
<div
class="tab-pane fade"
id="contact"
role="tabpanel"
aria-labelledby="contact-tab"
>
Contact Content
</div>
</div>
</div>
<div class="card-footer">
Footer
</div>
</div>
</body>
You don't need the .align-self-stretch class. You are running into problems with the original Bootstrap CSS for .card. To fix that you have to add the BS class .flex-grow-1 to your tab-content div.
Moreover, you have to make sure that your #myTextarea is set to height: 100%.
I hope this creates the effect you were looking for.
.card{
width: 400px;
height: 300px;
}
.tab-content{
display: flex;
}
.tab-pane{
width: 100%;
height: 100%;
}
.form-group{
width: 100%;
height: 100%;
}
#MyTextarea{
resize: none;
height: 100%;
}
<head>
<script src="https://code.jquery.com/jquery-3.6.0.slim.js" integrity="sha256-HwWONEZrpuoh951cQD1ov2HUK5zA5DwJ1DNUXaM6FsY=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<div class="card">
<div class="card-header">
Header
</div>
<div class="card-body d-flex flex-column">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="home-tab"
data-bs-toggle="tab"
data-bs-target="#home"
type="button"
role="tab"
aria-controls="home"
aria-selected="true"
>
Home
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="profile-tab"
data-bs-toggle="tab"
data-bs-target="#profile"
type="button"
role="tab"
aria-controls="profile"
aria-selected="false"
>
Profile
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="contact-tab"
data-bs-toggle="tab"
data-bs-target="#contact"
type="button"
role="tab"
aria-controls="contact"
aria-selected="false"
>
Contact
</button>
</li>
</ul>
<div class="tab-content d-flex flex-grow-1" id="myTabContent">
<div
class="tab-pane fade show active"
id="home"
role="tabpanel"
aria-labelledby="home-tab"
>
<div class="form-group">
<textarea class="form-control" id="MyTextarea" disabled>This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.</textarea>
</div>
</div>
<div
class="tab-pane fade"
id="profile"
role="tabpanel"
aria-labelledby="profile-tab"
>
Profile Content
</div>
<div
class="tab-pane fade"
id="contact"
role="tabpanel"
aria-labelledby="contact-tab"
>
Contact Content
</div>
</div>
</div>
<div class="card-footer">
Footer
</div>
</div>
</body>
Add flex-basis: 100%; to your #myTabContent. Next, just simply add h-100 or (height: 100%;) as a class on your textarea element.
.card{
width: 400px;
height: 300px;
}
.tab-content{
display: flex;
}
.tab-pane{
width: 100%;
height: 100%;
}
.form-group{
width: 100%;
height: 100%;
}
#myTabContent {
flex-basis: 100%;
}
#MyTextarea{
resize: none;
}
<head>
<script src="https://code.jquery.com/jquery-3.6.0.slim.js" integrity="sha256-HwWONEZrpuoh951cQD1ov2HUK5zA5DwJ1DNUXaM6FsY=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
</head>
<body>
<div class="card">
<div class="card-header">
Header
</div>
<div class="card-body d-flex flex-column">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="home-tab"
data-bs-toggle="tab"
data-bs-target="#home"
type="button"
role="tab"
aria-controls="home"
aria-selected="true"
>
Home
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="profile-tab"
data-bs-toggle="tab"
data-bs-target="#profile"
type="button"
role="tab"
aria-controls="profile"
aria-selected="false"
>
Profile
</button>
</li>
<li class="nav-item" role="presentation">
<button
class="nav-link"
id="contact-tab"
data-bs-toggle="tab"
data-bs-target="#contact"
type="button"
role="tab"
aria-controls="contact"
aria-selected="false"
>
Contact
</button>
</li>
</ul>
<div class="tab-content d-flex align-self-stretch" id="myTabContent">
<div
class="tab-pane fade show active"
id="home"
role="tabpanel"
aria-labelledby="home-tab"
>
<div class="form-group">
<textarea class="form-control h-100" id="MyTextarea" disabled>This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.This is some placeholder content the Home tab's associated content. Clicking another tab will toggle the visibility of this one for the next. The tab JavaScript swaps classes to control the content visibility and styling. You can use it with tabs, pills, and any other .nav-powered navigation.</textarea>
</div>
</div>
<div
class="tab-pane fade"
id="profile"
role="tabpanel"
aria-labelledby="profile-tab"
>
Profile Content
</div>
<div
class="tab-pane fade"
id="contact"
role="tabpanel"
aria-labelledby="contact-tab"
>
Contact Content
</div>
</div>
</div>
<div class="card-footer">
Footer
</div>
</div>
</body>

Bootstrap 5 tab nav not working in firefox and internet explorer

I am using Bootstrap 5 nav tabs but the tabs are not changing on Firefox version 89.0.2 and internet explorer 11+. There are no errors in the console.
cdn js:
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.1/dist/js/bootstrap.bundle.min.js"></script>
html:
<nav>
<div class="nav nav-tabs" id="dvtabs" role="tablist">
<button class="nav-link active" id="nav-contact-tab" data-bs-toggle="tab" data-bs-target="#nav-contact" type="button" role="tab" aria-controls="nav-contact" aria-selected="true">C</button>
<button class="nav-link" id="nav-associate-tab" data-bs-toggle="tab" data-bs-target="#nav-associate" type="button" role="tab" aria-controls="nav-associate" aria-selected="false">A</button>
</div>
</nav>
<div class="tab-content" id="dvtabcontent">
<div class="tab-pane fade show active" id="nav-contact" role="tabpanel" aria- labelledby="nav-contact-tab"></div>
<div class="tab-pane fade" id="nav-associate" role="tabpanel" aria- labelledby="nav-associate-tab"></div>
</div>
After a simple test, I found that it can work correctly in FireFox (referenced jquery 3.6.0 and bootstrap.css/js 5.0.1). I am not sure if you have referenced jquery and bootstrap.css. But it does not work in IE11. According to the error message in the console, I think the cause of the problem is that IE does not support arrow functions.
If you need to use bootstrap to achieve such a function, I recommend you to use bootstrap4. After testing, it can work correctly in IE11 using bootstrap4.
Simple test:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
</head>
<body>
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<button class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-home" aria-selected="true">C</button>
<button class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-associate" role="tab" aria-controls="nav-profile" aria-selected="false">A</button>
</div>
</nav>
<div class="tab-content" id="dvtabcontent">
<div class="tab-pane fade show active" id="nav-contact" role="tabpanel" aria- labelledby="nav-contact-tab">panel C</div>
<div class="tab-pane fade" id="nav-associate" role="tabpanel" aria- labelledby="nav-associate-tab">panel A</div>
</div>
</body>
</html>

Deep links for bootstrap tabs

I am trying to add deep linking for bootstrap tabs. It does add the tab id to the URL on each tab click but when I access the direct link (www.site.com/tabpage/#tab2) for the particular tab in a new browser window, it doesn't take me to the second tab. how can I make it work?
I need to get the direct URL to the particular tabs.
Here is the code used
HTML
<div class="tab_container">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item mr-4 no-gutter">
<a class="nav-link active" href="#tab1" role="tab" data-toggle="tab">Tab 1</a></li>
<li class="nav-item mr-4 no-gutter">
<a class="nav-link" href="#tab2" role="tab" data-toggle="tab">Tab 2</a></li>
<li class="nav-item mr-4 no-gutter">
<a class="nav-link" href="#tab3" role="tab" data-toggle="tab">Tab 3</a></li>
<li class="nav-item mr-4 no-gutter">
<a class="nav-link" href="#tab4" role="tab" data-toggle="tab">Tab 4</a></li>
</ul>
<div class="tab-content cisco-extralight p-4 pt-5 no-gutter">
<div role="tabpanel" class="tab-pane fade in active" id="tab1">
Tab 1 contenrt
</div>
<div role="tabpanel" class="tab-pane fade in active" id="tab2">
Tab 2 contenrt
</div>
<div role="tabpanel" class="tab-pane fade in active" id="tab3">
Tab 3 contenrt
</div>
<div role="tabpanel" class="tab-pane fade in active" id="tab4">
Tab 4 contenrt
</div>
</div>
</div>
JS
//tab deep linking
var url = window.location.href;
if (url.indexOf("#") > 0){
var activeTab = url.substring(url.indexOf("#") + 1);
$('.nav[role="tablist"] a[href="#'+activeTab+'"]').tab('show');
}
$('a[role="tab"]').on("click", function() {
var newUrl;
const hash = $(this).attr("href");
newUrl = url.split("#")[0] + hash;
history.replaceState(null, null, newUrl);
});

Nested tabs in a pill tab panel not working in Bootstrap

I'm having trouble getting tabs inside of a vertical pill tab panel to work correctly in Bootstrap 4.
Here's a minimal code example:
<html>
<head>
<link href="bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script src="popper.min.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<script src="bootstrap.min.js"></script>
<div class="row">
<div class="col-2">
<div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist">
<a class="nav-link active" data-toggle="pill" href="#v-pills-1" role="tab">Pill 1</a>
<a class="nav-link" data-toggle="pill" href="#v-pills-2" role="tab">Pill 2</a>
<a class="nav-link" data-toggle="pill" href="#v-pills-3" role="tab">Pill 3</a>
</div>
</div>
<div class="col-10">
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade active show" id="v-pills-1" role="tabpanel">
Pill 1 content
<!-- tabs
<ul class="nav nav-tabs nav-fill" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tabs-1" role="tab">Tab 1</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tabs-2" role="tab">Tab 2</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tabs-3" role="tab">Tab 3</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active show" id="tabs-1" role="tabpanel">Tab 1 content</div>
<div class="tab-pane" id="tabs-2" role="tabpanel">Tab 2 content</div>
<div class="tab-pane" id="tabs-3" role="tabpanel">Tab 3 content</div>
</div>
-->
</div>
<div class="tab-pane fade" id="v-pills-2" role="tabpanel">Pill 2 content</div>
<div class="tab-pane fade" id="v-pills-3" role="tabpanel">Pill 3 content</div>
</div>
</div>
</div>
</body>
</html>
The webpage functions correctly, that is the vertical pills work as expected. Once you uncomment the section that gives the first vertical pill a nested tab, the pills do not function correctly. Clicking on Pill 2 and then Pill 3 will results in the content for both pills to be shown.
Why doesn't this work and how can I fix it?
This is a bug in version 4.0.0-beta. It is fixed in version 4.0.0-beta.2:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>