无法禁用jQuery UI选项卡

use*_*866 2 jquery-ui jquery-ui-tabs

API说你无法禁用我认为是问题症结的活动标签.

我在一个UI标签中有六个标签.在ajax调用之后,其中一个选项卡有时是空的,以便根据用户点击新的UI Accordion选项为所有选项卡填充数据.每当用户进行新选择时,我都会使用"零"选项卡作为默认选定选项卡.

我使用以下代码在php文件中进行编码,该文件加载有时空的选项卡以禁用标签为空时.除非用户在单击新的UI Accordion选项时选择了此选项卡,否则它可以正常工作.仅在这种情况下,空选项卡将保持启用状态.

?>
    <script type="text/javascript">
      $(document).ready(function() {
          $( "#tabs" ).tabs( "option", "disabled", false);
      });
    </script>
<?php
}else{ 
?>
    <script type="text/javascript">
      $(document).ready(function() {
          $( "#tabs" ).tabs( "option", "disabled", [2]);
      });
    </script>
Run Code Online (Sandbox Code Playgroud)

有人可以提出一个策略吗?

这是包含ajax调用的脚本:

<script type="text/javascript">                
    $('.stallion').live('click', function(){
 var id = parseInt(this.id);  // Get stallion_ID from clicked "a" tag id.
 activestallion(id);  // Function to indicate clicked Stallion in Stallion Accordion
        // Start loading Overview Tab
        var request = $.ajax({
            url: "stalliondetails.php",
            type: "GET",
            data: {stallion_ID : id}
        });
        request.done( function(html){
            $("#tabs-1").html(html);
            $( "#tabs" ).tabs( "option", "selected", 0 );
            $(".activehorse").fadeOut('1000', function(){
            document.getElementById("activehorsename").innerHTML
                 =document.getElementById(id).innerHTML;
            $(".activehorse").fadeIn('1000');
            });
            $("#tabs").tabs( "select" , 0 );
        });
        // Overview Tab load finished.
        //Pedigree Tab load starting.
        var request = $.ajax({
        url: "pedigreedetails.php",
        type: "GET",
        data: {stallion_ID : id},
        success: function(html){
        $("#tabs-2").html(html);
        }
        });    
        //Pedigree Tab load finished.
        //Progeny Tab load starting.
        var request = $.ajax({
        url: "progenydetails.php",
        type: "GET",
        data: {stallion_ID : id},
        success: function(html){
        $("#tabs-3").html(html);
        }
        });    
        //Progeny Tab load finished.
        //News Tab load starting.
        var request = $.ajax({
        url: "newsdetails.php",
        type: "GET",
        data: {stallion_ID : id},
        success: function(html){
        $("#tabs-4").html(html);
        }
        });    
        //News Tab load finished.
        //Race Record Tab load starting.
        var request = $.ajax({
        url: "racerecorddetails.php",
        type: "GET",
        data: {stallion_ID : id},
        success: function(html){
        $("#tabs-5").html(html);
        }
        });    
        //Race Record Tab load finished.
        //Analysis Tab load starting.
        var request = $.ajax({
        url: "analysisdetails.php",
        type: "GET",
        data: {stallion_ID : id},
        success: function(html){
        $("#tabs-6").html(html);
        }
        });    
        //Analysis Tab load finished.
        //Update the Seasons Request form to this Stallion.
        updateseasons(id);
        $( "#tabs" ).tabs( "option", "selected", 0 );
        $("button").button() ;       
  });
</script>
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

use*_*866 6

为了帮助其他人遵循这个主题,我想发布最终修复此问题的内容.

我在用

$("#tabs").tabs("option", "disabled", [2]);
Run Code Online (Sandbox Code Playgroud)

当我切换到

$("#tabs").tabs("disable", 2);
Run Code Online (Sandbox Code Playgroud)

问题得到纠正.

感谢巴特和威廉的帮助.