I've searched and found a few similar answers - but those were surrounding accordions which I am not using.
I have nested collapse items as seen in this codepen
$('#collapseOutter').on('show.bs.collapse', function(event) {
$('#collapseBtn').html("Show Less");
console.log('Only happen when outter div is opened');
event.stopPropagation();
console.log('even with stopping propagation it fires');
})
$('#collapseOutter').on('hide.bs.collapse', function() {
$('#collapseBtn').html("Show More");
console.log('Only happen when outter div is collapsed');
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row ml-4">
<div class="row header-div">
<a id="collapseBtn" class="btn-info btn" data-toggle="collapse" href="#collapseOutter" role="button" aria-expanded="false" aria-controls="collapseOutter">
Show More
</a>
</div>
</div>
<div class="row ml-4">
<div id="collapseOutter" class="collapse">
<p>Here is a paragraph about the data you're about to see.</p>
<div class="row">
<div id="item-a">
<a id="item-a" class="" data-toggle="collapse" href="#collapseInnerA">
Item One of a list
</a>
<br />
<div id="collapseInnerA" class="collapse">
<div class="row">
<p class="ml-4">Item One Related Information</p>
</div>
</div>
</div>
</div>
<div class="row">
<div id="item-b">
<a id="item-b" class="" data-toggle="collapse" href="#collapseInnerB">
Item Two of a list
</a>
<br />
<div id="collapseInnerB" class="collapse">
<div class="row">
<p class="ml-4">Item Two Related Information</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
When I click on the items in the list (which is inside the 1st collapse) it causes the parent methods to fire.
How do I prevent the parent methods from firing when I click on the list items to collapse/show their information?
I'm looking to see how I can do this relating to bootstrap specifically.