JQuery Tabs首次单独使用Ajax加载

时间:2012-02-03 06:04:13

标签: jquery-ui jquery jquery-selectors

我正在使用基于组合框选择的ajax在jquery选项卡中加载数据它第一次工作正常,如果我在那时更改组合框选择,如果我切换到第二个选项卡,第一个选项卡变为空,则数据正确加载并且第一个选项卡出现,然后数据加载正常。我不知道为什么在第一个选项卡中更改combox选择时没有加载。

在下面的示例中,我检查条件如“值 L ”,如果它是“L”那么我需要显示三个标签,如果值是不是“L”然后我需要显示两个标签。

当两个标签显示时,第一个标签数据未​​加载。

 $(function() {
     $("#contractType").change(function(){                          

            if($("#contractType").val()=="L") //Combo Selection Values
                {                       
                    $("#hidetab").show();//Loading tabs
                    $("#tabs-0").show();
                    $("#dispEmp").removeClass('ui-tabs-selected ui-state-active');

                }//if

            else
                {
                    $("#hidetab").hide();
                    $("#tabs-0").hide();//Hides the first tab                       
                    $("#tabs-1").show();/*Displays remaining two tabs below*/
                    $("#tabs-2").show();
                    $("#dispEmp").addClass('ui-tabs-selected ui-state-active');
                    $("#jqgrid").show();//Here i am trying to load the data in second tab using ajax call.
                    $("#dispEquip").removeClass('ui-tabs-selected ui-state-active');

                }

     });         

 }); 

1 个答案:

答案 0 :(得分:1)

我得到了答案,现在工作正常。

我正在根据我选择的标签条件更改组合框。

$( "#yourtabId" ).tabs( "option", "selected", 0 );//this code will select the index of the tab as selected.

0->标签索引。

如果我们需要返回选项卡索引值,则在选择选项卡时,将调用此函数。

$('#yourtabId').tabs({
            select: function(event, ui) {

            ui.index // Will return the selected index of the tabs.
          }
        });