I am using bootsrap tabs for a registration form , I changed navigation of tabs using onclick event of next and previous button . But still that tabs click works and being able to go the desired page easily Please help how can i stop tab click navigation i only want next previous button navigation Please find the html code below
<ul class="nav nav-tabs" id="myTab">
<li class="active">
<a href="#home" data-toggle="tab">1.PERSONAL DETAILS</a>
</li>
<li>
<a href="#profile" data-toggle="tab"> 2. CONTACT DETAILS</a>
</li>
<li>
<a href="#messages" data-toggle="tab">3. EDUCATION DETAILS</a>
</li>
<li>
<a href="#course" data-toggle="tab">4. SELECT COURSE</a>
</li>
<li>
<a href="#settings" data-toggle="tab">5. PAYMENT DETAILS</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="home">Form elements </div>
<div id="profile">Form elements </div>
<div id="messages">Form elements </div>
<div id="settings">Form elements </div>
</div>
I have tabs like this in the HTML (using Bootstrap 3.0):
<ul class="nav nav-tabs" id="createNotTab">
<li class="active" ><a href="#home" data-toggle="tab">Step 1: Select Property</a></li>
<li class="disabled"><a href="#createnotification" data-toggle="" >Step 2: Create Notification</a></li>
</ul>
Next/Previous buttons
<button class="btn btn-warning prevtab" type="button" onclick="return showPrev()"><span class="glyphicon glyphicon-arrow-left"></span>Previous </button>
<button class="btn btn-info prevtab" type="button" onclick="return showNext()"><span class="glyphicon glyphicon-arrow-right"></span>Next </button>
In my JavaScript file:
var $tabs = $('#createNotTab li');
function showPrev() {
$tabs.filter('.active').prev('li').removeClass("disabled");
$tabs.filter('.active').prev('li').find('a[data-toggle]').each(function () {
$(this).attr("data-toggle", "tab");
});
$tabs.filter('.active').prev('li').find('a[data-toggle="tab"]').tab('show');
$tabs.filter('.active').next('li').find('a[data-toggle="tab"]').each(function () {
$(this).attr("data-toggle", "").parent('li').addClass("disabled");
})
}
function showNext() {
$tabs.filter('.active').next('li').removeClass("disabled");
$tabs.filter('.active').next('li').find('a[data-toggle]').each(function () {
$(this).attr("data-toggle", "tab");
});
$tabs.filter('.active').next('li').find('a[data-toggle="tab"]').tab('show');
$tabs.filter('.active').prev('li').find('a[data-toggle="tab"]').each(function () {
$(this).attr("data-toggle", "").parent('li').addClass("disabled");;
})
}
If you are having multiple tabs, set class="disabled"
and data-toggle=""
for all the li items that you want to deactivate.
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