Bootstrap Tabs禁用和使用jQuery [英] Bootstrap tabs pills disabling and with jQuery

查看:158
本文介绍了Bootstrap Tabs禁用和使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了以下示例,并尝试添加其他功能.我想先禁用其他两个表,然后从第一个选项卡提交表单,然后启用第二个选项卡.我尝试使用jQuery UO和jQuery.但是无法使用Bootstrap和jQuery.

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演示

这是我到目前为止尝试过的.

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>    

这篇关于Bootstrap Tabs禁用和使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆