I looked at the below example and am trying to add additional functionality. I would like to disable other two tables initially and when I submit the form from first tab and then enable second tab. I have tried using jQuery UO and jQuery. But not able to do with Bootstrap and jQuery.
jsFiddle Demo
Here is what I have tried so far.
$(document).ready(function() {
$('#profile').attr('class', 'disabled');
$('#message').attr('class', 'disabled');
$('#profile').removeAttr('data-toggle');
$('#messages').removeAttr('data-toggle');
});
To disable the other two tabs and later on enable them on an event you can do the following,
http://jsfiddle.net/5zjXk/1/
js
$(document).ready(function() {
/*disable non active tabs*/
$('.nav li').not('.active').addClass('disabled');
/*to actually disable clicking the bootstrap tab, as noticed in comments by user3067524*/
$('.nav li').not('.active').find('a').removeAttr("data-toggle");
$('button').click(function(){
/*enable next tab*/
$('.nav li.active').next('li').removeClass('disabled');
$('.nav li.active').next('li').find('a').attr("data-toggle","tab")
});
});
html
<ul class="nav nav-pills">
<li class="active"><a href="#home" data-toggle="tab">Home</a></li>
<li><a href="#profile" data-toggle="tab">Profile</a></li>
<li><a href="#messages" data-toggle="tab">Messages</a></li>
</ul>
<div id='content' class="tab-content">
<div class="tab-pane active" id="home">
<ul>
<li>home</li>
<li>home</li>
<li>home</li>
<li>home</li>
</ul>
<button>submit</button>
</div>
<div class="tab-pane" id="profile">
<ul>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
<li>profile</li>
</ul>
<button>submit</button>
</div>
<div class="tab-pane" id="messages">
Tetsing
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With