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>
有人可以建议一个策略吗?
这是包含 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>
谢谢你的帮助。