2011-12-09 60 views
2

该API说你不能禁用活动选项卡,我认为这是我的问题的关键。麻烦禁用jQuery UI选项卡

我在一个UI选项卡中有六个选项卡。在ajax调用之后,其中一个选项卡有时为空,以便根据用户点击新的UI手风琴选项来填充所有选项卡。每当用户进行新选择时,我都会使用“零”选项卡作为默认选定选项卡。

我使用以下代码在PHP文件中加载有时为空的选项卡,以在其为空时禁用选项卡。它可以正常工作,除非用户在单击新的UI手风琴选项时选择了此选项卡。在这种情况下,空标签将保持启用状态。

?> 
    <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> 

有人可以建议一个战术?

下面是一个包含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> 

感谢您的帮助。

回答

3

尝试

<script type="text/javascript"> 
    $(document).ready(function() { 
     $("#tabs").tabs("option", "disabled", 2); 
    }); 
</script> 

或多禁用

<script type="text/javascript"> 
    $(document).ready(function() { 
     $("#tabs").tabs('option','disabled', [1, 2, 3, 4]); 
    }); 
</script> 

,而不是

<script type="text/javascript"> 
    $(document).ready(function() { 
     $("#tabs").tabs("option", "disabled", [2]); 
    }); 
</script> 

,使标签和移动使用

$("#tabs").tabs("enable" , 1) 
    $("#tabs").tabs("select" , 1) 

*从0开始计数

+0

使用:$(“#tabs”).tabs(“option”,“disabled”,2); – user1028866

+0

使用: $(“#tabs”).tabs(“option”,“disabled”,2); (“#tabs”).tabs(“option”,“disabled”,[2]);代替: 不起作用。花了我一段时间来找到有效的方括号。我所展示的代码除非在第三个选项卡处于活动状态(显示)时调用$('。stallion')。live('click',function(),否则该函数中的所有内容都会正确触发, “第三个”选项卡是空的或不是空的,这很难描述,如果你不遵循我的意思,请告诉我,谢谢你的帮助。 – user1028866

+1

它应该是'.tabs(“disable “,2)'而不是'.tabs(”option“,”disabled“,2)' –

6

为了帮助他人关注此主题,我想发布最终解决此问题的方案。

我用

$("#tabs").tabs("option", "disabled", [2]); 

当我切换到

$("#tabs").tabs("disable", 2); 

的问题已得到解决。

感谢您的帮助巴特和威廉。