I'm trying to make a Javascript action when a bootstrap tab is opened. I can't get it to work. These are the scripts I've tried:
$('.nav-tabs a').on('shown.bs.tab', function(){
vchart.redraw();
});
And
$(document).ready(function(){
$(".nav-tabs a").click(function(){
$(this).tab('show');
});
$('.nav-tabs a').on('shown.bs.tab', function(){
vchart.redraw();
});
});
I have these scripts inside of the tabs themselves. I also tried:
$('ul.nav a').on('shown.bs.tab', function (e) {
instead of
$('.nav-tabs a').on('shown.bs.tab', function(){
Some HTML
<div class="col-md-9">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" href="#1">Tab 1</a>
</li>
<li>
<a data-toggle="tab" href="#2">Tab 2</a>
</li>
</ul>
</div>
<div id="1" class="tab-pane fade in active">
Tab 1 content...
</div>
<div id="2" class="tab-pane">
Tab 2 content...
</div>
What is going on?